| 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 | //$time_new = $date_time->format('H:i:s')
|
|---|
| 30 | if($days == $timestamp2)
|
|---|
| 31 | {
|
|---|
| 32 | ?>
|
|---|
| 33 | cnt++;
|
|---|
| 34 |
|
|---|
| 35 | $('#save').hide();
|
|---|
| 36 | $('#update').show();
|
|---|
| 37 | var div= document.createElement("div");
|
|---|
| 38 | div.setAttribute('id','TableHolder');
|
|---|
| 39 | var table = document.createElement("table");
|
|---|
| 40 | table.setAttribute('id',"table"+cnt);
|
|---|
| 41 | table.setAttribute('width','100%');
|
|---|
| 42 | var tr = document.createElement('tr');
|
|---|
| 43 | var td3=document.createElement('td');
|
|---|
| 44 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 45 | td3.appendChild(
|
|---|
| 46 | input = document.createElement("input"),
|
|---|
| 47 | input.setAttribute("type","time"),
|
|---|
| 48 | input.setAttribute("id","Time"),
|
|---|
| 49 | input.setAttribute("max","24"),
|
|---|
| 50 | input.setAttribute("min","1"),
|
|---|
| 51 | input.setAttribute("required",true),
|
|---|
| 52 | input.setAttribute("value",'<?php echo $date_time; ?>')
|
|---|
| 53 |
|
|---|
| 54 | );
|
|---|
| 55 | td3.appendChild(
|
|---|
| 56 | button=document.createElement('input'),
|
|---|
| 57 | button.setAttribute('type','button'),
|
|---|
| 58 | button.setAttribute('value','[+]'),
|
|---|
| 59 | button.setAttribute('id','btnAddTime'),
|
|---|
| 60 | button.setAttribute('name','#table'+cnt),
|
|---|
| 61 | button.onclick=function(){
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | if($('#Time').val() != ""){ var splitting = $('#Time').val().split(':'); var add = 01;
|
|---|
| 65 |
|
|---|
| 66 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 67 |
|
|---|
| 68 | function pad(number, length) {
|
|---|
| 69 |
|
|---|
| 70 | var str = '' + number;
|
|---|
| 71 | while (str.length < length) {
|
|---|
| 72 | str = '0' + str;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | return str;
|
|---|
| 76 |
|
|---|
| 77 | }
|
|---|
| 78 | var s = 0; var get;
|
|---|
| 79 | var nn;
|
|---|
| 80 | nn = $(this).attr('name');
|
|---|
| 81 | $("table").each(function() {
|
|---|
| 82 | if($(this).attr("name")==nn){
|
|---|
| 83 |
|
|---|
| 84 | get = "#"+$(this).attr("id");
|
|---|
| 85 | //get = $(this).attr("name");
|
|---|
| 86 | s =1;
|
|---|
| 87 | }else{
|
|---|
| 88 | if(s==0){
|
|---|
| 89 | get = '#table'+cnt;
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 | });
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | getTableId =get;
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 | name="name"; value=""; meas = "name"; meas2 = "time"; // getTableId = $(this).attr('name');
|
|---|
| 100 | split1(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 | }
|
|---|
| 104 | );
|
|---|
| 105 | var td=document.createElement('td');
|
|---|
| 106 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 107 | td.appendChild(
|
|---|
| 108 | sourcecbo= document.createElement('select'),
|
|---|
| 109 | sourcecbo.setAttribute('id','source'),
|
|---|
| 110 | <?php
|
|---|
| 111 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 112 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 113 | {
|
|---|
| 114 | ?>
|
|---|
| 115 | sourcecbo.appendChild(
|
|---|
| 116 | option=document.createElement('option'),
|
|---|
| 117 |
|
|---|
| 118 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 119 | <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 | ),
|
|---|
| 126 | <?php
|
|---|
| 127 | }
|
|---|
| 128 | ?>
|
|---|
| 129 | sourcecbo.setAttribute('id','source')
|
|---|
| 130 |
|
|---|
| 131 | );
|
|---|
| 132 | var td1=document.createElement('td');
|
|---|
| 133 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 134 | td1.appendChild(
|
|---|
| 135 | measurementcbo= document.createElement('select'),
|
|---|
| 136 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 137 | <?php
|
|---|
| 138 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 139 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 140 | {
|
|---|
| 141 | ?>
|
|---|
| 142 | measurementcbo.appendChild(
|
|---|
| 143 | option=document.createElement('option'),
|
|---|
| 144 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 145 |
|
|---|
| 146 | <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?>
|
|---|
| 147 |
|
|---|
| 148 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 149 | ),
|
|---|
| 150 | <?php
|
|---|
| 151 | }
|
|---|
| 152 | ?>
|
|---|
| 153 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 154 | );
|
|---|
| 155 | td1.appendChild(
|
|---|
| 156 | button=document.createElement('input'),
|
|---|
| 157 | button.setAttribute('type','button'),
|
|---|
| 158 | button.setAttribute('value','[+]'),
|
|---|
| 159 | button.setAttribute('id','btnAddTime'),
|
|---|
| 160 | button.setAttribute('name','#table'+cnt),
|
|---|
| 161 | button.onclick=function(){
|
|---|
| 162 | 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"); }
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 | }
|
|---|
| 166 | );
|
|---|
| 167 | var td2=document.createElement('td');
|
|---|
| 168 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 169 | td2.appendChild(
|
|---|
| 170 | input = document.createElement('input'),
|
|---|
| 171 | input.setAttribute('type','text'),
|
|---|
| 172 | input.setAttribute('id','txtData'),
|
|---|
| 173 | input.setAttribute('value','<?php echo $rows['fData']; ?>')
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 | );
|
|---|
| 177 | var td4=document.createElement('td');
|
|---|
| 178 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 179 | td4.appendChild(
|
|---|
| 180 | button = document.createElement('input'),
|
|---|
| 181 | button.setAttribute("type",'button'),
|
|---|
| 182 | button.setAttribute('id','btnSplit'),
|
|---|
| 183 | button.setAttribute('value','Split'),
|
|---|
| 184 | button.setAttribute('name','#table'+cnt),
|
|---|
| 185 | button.onclick= function()
|
|---|
| 186 | {
|
|---|
| 187 |
|
|---|
| 188 | if($('#Time').val() != ""){ var splitting = $('#Time').val().split(':'); var add = 30;
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 | var limit = 60;
|
|---|
| 192 | var adds =0;
|
|---|
| 193 | adds = (Number(splitting[1]) + Number(add));
|
|---|
| 194 | if(adds >= limit){
|
|---|
| 195 | adds = Number(adds) - Number(limit);
|
|---|
| 196 | timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
|
|---|
| 197 |
|
|---|
| 198 | }else{
|
|---|
| 199 |
|
|---|
| 200 | timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
|
|---|
| 201 | }
|
|---|
| 202 | function pad(number, length) {
|
|---|
| 203 |
|
|---|
| 204 | var str = '' + number;
|
|---|
| 205 | while (str.length < length) {
|
|---|
| 206 | str = '0' + str;
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | return str;
|
|---|
| 210 |
|
|---|
| 211 | };
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 | name="name"; value="";
|
|---|
| 215 | meas = "name"; meas2 = "time";
|
|---|
| 216 | getTableId = $(this).attr('name');
|
|---|
| 217 | split1();
|
|---|
| 218 | }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | }
|
|---|
| 223 | );
|
|---|
| 224 | td4.appendChild(
|
|---|
| 225 | button=document.createElement('input'),
|
|---|
| 226 | button.setAttribute('type','button'),
|
|---|
| 227 | button.setAttribute('value','Delete'),
|
|---|
| 228 | button.setAttribute('id','btnDelete'),
|
|---|
| 229 | button.onclick=function(){
|
|---|
| 230 | $('#table'+cnt).remove();
|
|---|
| 231 | }
|
|---|
| 232 | );
|
|---|
| 233 |
|
|---|
| 234 | tr.appendChild(td3);
|
|---|
| 235 | tr.appendChild(td1);
|
|---|
| 236 | tr.appendChild(td);
|
|---|
| 237 |
|
|---|
| 238 | tr.appendChild(td2);
|
|---|
| 239 | tr.appendChild(td4);
|
|---|
| 240 | table.appendChild(tr);
|
|---|
| 241 | div.appendChild(table);
|
|---|
| 242 | $('#TableH1').append(div);
|
|---|
| 243 |
|
|---|
| 244 | <?php
|
|---|
| 245 | }
|
|---|
| 246 | }
|
|---|
| 247 | ?>
|
|---|
| 248 |
|
|---|
| 249 | if(cnt==0)
|
|---|
| 250 | {
|
|---|
| 251 | $('#save').show();
|
|---|
| 252 | $('#update').hide();
|
|---|
| 253 | var div= document.createElement("div");
|
|---|
| 254 | div.setAttribute('id','TableHolder');
|
|---|
| 255 | var table = document.createElement("table");
|
|---|
| 256 | table.setAttribute('id',"table2");
|
|---|
| 257 | table.setAttribute('width','100%');
|
|---|
| 258 | var tr = document.createElement('tr');
|
|---|
| 259 | tr.setAttribute('id','');
|
|---|
| 260 | tr.setAttribute('class','');
|
|---|
| 261 | var td3=document.createElement('td');
|
|---|
| 262 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 263 | td3.appendChild(
|
|---|
| 264 | input = document.createElement("input"),
|
|---|
| 265 | input.setAttribute("type","time"),
|
|---|
| 266 | input.setAttribute("id","Time"),
|
|---|
| 267 | input.setAttribute("max","24"),
|
|---|
| 268 | input.setAttribute("min","1"),
|
|---|
| 269 | input.setAttribute("required",true)
|
|---|
| 270 | );
|
|---|
| 271 | td3.appendChild(
|
|---|
| 272 | button=document.createElement('input'),
|
|---|
| 273 | button.setAttribute('type','button'),
|
|---|
| 274 | button.setAttribute('value','[+]'),
|
|---|
| 275 | button.setAttribute('id','btnAddTime'),
|
|---|
| 276 | button.setAttribute('name','#table2'),
|
|---|
| 277 | button.onclick=function(){
|
|---|
| 278 | var aa;
|
|---|
| 279 | $('div#TableHolder #table2 #Time').each(function(){
|
|---|
| 280 | aa = $(this).val();
|
|---|
| 281 | });
|
|---|
| 282 | if(aa != ""){ var splitting =aa.split(':'); var add = 01;
|
|---|
| 283 |
|
|---|
| 284 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 285 |
|
|---|
| 286 | function pad(number, length) {
|
|---|
| 287 |
|
|---|
| 288 | var str = '' + number;
|
|---|
| 289 | while (str.length < length) {
|
|---|
| 290 | str = '0' + str;
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | return str;
|
|---|
| 294 |
|
|---|
| 295 | };
|
|---|
| 296 |
|
|---|
| 297 | var s = 0; var get;
|
|---|
| 298 |
|
|---|
| 299 | $("table").each(function() {
|
|---|
| 300 | if($(this).attr("name")=='#table2'){
|
|---|
| 301 | get = "#"+$(this).attr("id");
|
|---|
| 302 |
|
|---|
| 303 | s =1;
|
|---|
| 304 | }else{
|
|---|
| 305 | if(s==0){
|
|---|
| 306 | get = '#table'+cnt;
|
|---|
| 307 | }
|
|---|
| 308 | }
|
|---|
| 309 | });
|
|---|
| 310 | getTableId =get;
|
|---|
| 311 | name="name"; value="";
|
|---|
| 312 | name="name"; value=""; meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
|
|---|
| 313 | split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 | }
|
|---|
| 317 | );
|
|---|
| 318 | var td=document.createElement('td');
|
|---|
| 319 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 320 | td.appendChild(
|
|---|
| 321 | sourcecbo= document.createElement('select'),
|
|---|
| 322 | sourcecbo.setAttribute('id','source'),
|
|---|
| 323 | <?php
|
|---|
| 324 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 325 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 326 | {
|
|---|
| 327 | ?>
|
|---|
| 328 | sourcecbo.appendChild(
|
|---|
| 329 | option=document.createElement('option'),
|
|---|
| 330 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 331 | option.setAttribute('selected',true),
|
|---|
| 332 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 333 |
|
|---|
| 334 | ),
|
|---|
| 335 | <?php
|
|---|
| 336 | }
|
|---|
| 337 | ?>
|
|---|
| 338 | sourcecbo.setAttribute('id','source')
|
|---|
| 339 |
|
|---|
| 340 | );
|
|---|
| 341 | var td1=document.createElement('td');
|
|---|
| 342 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 343 | td1.appendChild(
|
|---|
| 344 | measurementcbo= document.createElement('select'),
|
|---|
| 345 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 346 | <?php
|
|---|
| 347 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 348 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 349 | {
|
|---|
| 350 | ?>
|
|---|
| 351 | measurementcbo.appendChild(
|
|---|
| 352 | option=document.createElement('option'),
|
|---|
| 353 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 354 | option.setAttribute('selected',true),
|
|---|
| 355 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 356 | ),
|
|---|
| 357 | <?php
|
|---|
| 358 | }
|
|---|
| 359 | ?>
|
|---|
| 360 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 361 | );
|
|---|
| 362 | td1.appendChild(
|
|---|
| 363 | button=document.createElement('input'),
|
|---|
| 364 | button.setAttribute('type','button'),
|
|---|
| 365 | button.setAttribute('value','[+]'),
|
|---|
| 366 | button.setAttribute('id','btnAddTime'),
|
|---|
| 367 | button.setAttribute('name','#table2'),
|
|---|
| 368 | button.onclick=function(){
|
|---|
| 369 | var aa;
|
|---|
| 370 | $('div#TableHolder #table2 #Time').each(function(){
|
|---|
| 371 | aa = $(this).val();
|
|---|
| 372 | });
|
|---|
| 373 | 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"); }
|
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 | }
|
|---|
| 377 | );
|
|---|
| 378 | var td2=document.createElement('td');
|
|---|
| 379 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 380 | td2.appendChild(
|
|---|
| 381 | input = document.createElement('input'),
|
|---|
| 382 | input.setAttribute('type','text'),
|
|---|
| 383 | input.setAttribute('id','txtData')
|
|---|
| 384 |
|
|---|
| 385 | );
|
|---|
| 386 | var td4=document.createElement('td');
|
|---|
| 387 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 388 | td4.appendChild(
|
|---|
| 389 | button = document.createElement('input'),
|
|---|
| 390 | button.setAttribute("type",'button'),
|
|---|
| 391 | button.setAttribute('id','btnSplit'),
|
|---|
| 392 | button.setAttribute('value','Split'),
|
|---|
| 393 | button.setAttribute('name','#table2'),
|
|---|
| 394 | button.onclick= function()
|
|---|
| 395 | {
|
|---|
| 396 | var aa;
|
|---|
| 397 | $('div#TableHolder #table2 #Time').each(function(){
|
|---|
| 398 | aa = $(this).val();
|
|---|
| 399 | });
|
|---|
| 400 | if(aa != ""){ var splitting = aa.split(':'); var add = 30; var limit = 60;
|
|---|
| 401 | var adds =0;
|
|---|
| 402 | adds = (Number(splitting[1]) + Number(add));
|
|---|
| 403 | if(adds >= limit){
|
|---|
| 404 | adds = Number(adds) - Number(limit);
|
|---|
| 405 | timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
|
|---|
| 406 |
|
|---|
| 407 | }else{
|
|---|
| 408 |
|
|---|
| 409 | timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
|
|---|
| 410 | }
|
|---|
| 411 | function pad(number, length) {
|
|---|
| 412 |
|
|---|
| 413 | var str = '' + number;
|
|---|
| 414 | while (str.length < length) {
|
|---|
| 415 | str = '0' + str;
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | return str;
|
|---|
| 419 |
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | meas = "name"; meas2 = "time"; getTableId = $(this).attr('name');
|
|---|
| 423 | split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 424 |
|
|---|
| 425 | }
|
|---|
| 426 | );
|
|---|
| 427 | td4.appendChild(
|
|---|
| 428 | button=document.createElement('input'),
|
|---|
| 429 | button.setAttribute('type','button'),
|
|---|
| 430 | button.setAttribute('value','Delete'),
|
|---|
| 431 | button.setAttribute('id','btnDelete'),
|
|---|
| 432 | button.onclick=function(){
|
|---|
| 433 | $('#table2').remove();
|
|---|
| 434 |
|
|---|
| 435 | }
|
|---|
| 436 | );
|
|---|
| 437 |
|
|---|
| 438 | tr.appendChild(td3);
|
|---|
| 439 | tr.appendChild(td1);
|
|---|
| 440 | tr.appendChild(td);
|
|---|
| 441 |
|
|---|
| 442 | tr.appendChild(td2);
|
|---|
| 443 | tr.appendChild(td4);
|
|---|
| 444 | table.appendChild(tr);
|
|---|
| 445 | div.appendChild(table);
|
|---|
| 446 | $('#TableH1').append(div);
|
|---|
| 447 |
|
|---|
| 448 | var div= document.createElement("div");
|
|---|
| 449 | div.setAttribute('id','TableHolder');
|
|---|
| 450 | var table = document.createElement("table");
|
|---|
| 451 | table.setAttribute('id',"table1");
|
|---|
| 452 | table.setAttribute('width','100%');
|
|---|
| 453 | var tr = document.createElement('tr');
|
|---|
| 454 | tr.setAttribute('id','');
|
|---|
| 455 | tr.setAttribute('class','');
|
|---|
| 456 | var td3=document.createElement('td');
|
|---|
| 457 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 458 | td3.appendChild(
|
|---|
| 459 | input = document.createElement("input"),
|
|---|
| 460 | input.setAttribute("type","time"),
|
|---|
| 461 | input.setAttribute("id","Time"),
|
|---|
| 462 | input.setAttribute("max","24"),
|
|---|
| 463 | input.setAttribute("min","1"),
|
|---|
| 464 | input.setAttribute("required",true)
|
|---|
| 465 | );
|
|---|
| 466 | td3.appendChild(
|
|---|
| 467 | button=document.createElement('input'),
|
|---|
| 468 | button.setAttribute('type','button'),
|
|---|
| 469 | button.setAttribute('value','[+]'),
|
|---|
| 470 | button.setAttribute('id','btnAddTime'),
|
|---|
| 471 | button.setAttribute('name','#table1'),
|
|---|
| 472 | button.onclick=function(){
|
|---|
| 473 | var aa;
|
|---|
| 474 | $('div#TableHolder #table1 #Time').each(function(){
|
|---|
| 475 | aa = $(this).val();
|
|---|
| 476 | });
|
|---|
| 477 |
|
|---|
| 478 | if(aa != ""){ var splitting = aa.split(':'); var add = 01;
|
|---|
| 479 |
|
|---|
| 480 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 481 |
|
|---|
| 482 | function pad(number, length) {
|
|---|
| 483 |
|
|---|
| 484 | var str = '' + number;
|
|---|
| 485 | while (str.length < length) {
|
|---|
| 486 | str = '0' + str;
|
|---|
| 487 | }
|
|---|
| 488 |
|
|---|
| 489 | return str;
|
|---|
| 490 |
|
|---|
| 491 | };
|
|---|
| 492 |
|
|---|
| 493 |
|
|---|
| 494 | var s = 0; var get;
|
|---|
| 495 |
|
|---|
| 496 | $("table").each(function() {
|
|---|
| 497 | if($(this).attr("name")=='#table1'){
|
|---|
| 498 | get = "#"+$(this).attr("id");
|
|---|
| 499 |
|
|---|
| 500 | s =1;
|
|---|
| 501 | }else{
|
|---|
| 502 | if(s==0){
|
|---|
| 503 | get = '#table'+cnt;
|
|---|
| 504 | }
|
|---|
| 505 | }
|
|---|
| 506 | });
|
|---|
| 507 | getTableId =get;
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 | name="name"; value=""; meas = "class"; meas2 = "time"; //getTableId = $(this).attr('name');
|
|---|
| 511 | split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 | }
|
|---|
| 515 | );
|
|---|
| 516 | var td=document.createElement('td');
|
|---|
| 517 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 518 | td.appendChild(
|
|---|
| 519 | sourcecbo= document.createElement('select'),
|
|---|
| 520 | sourcecbo.setAttribute('id','source'),
|
|---|
| 521 | <?php
|
|---|
| 522 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 523 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 524 | {
|
|---|
| 525 | ?>
|
|---|
| 526 | sourcecbo.appendChild(
|
|---|
| 527 | option=document.createElement('option'),
|
|---|
| 528 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 529 | option.setAttribute('selected',true),
|
|---|
| 530 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 531 |
|
|---|
| 532 | ),
|
|---|
| 533 | <?php
|
|---|
| 534 | }
|
|---|
| 535 | ?>
|
|---|
| 536 | sourcecbo.setAttribute('id','source')
|
|---|
| 537 |
|
|---|
| 538 | );
|
|---|
| 539 | var td1=document.createElement('td');
|
|---|
| 540 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 541 | td1.appendChild(
|
|---|
| 542 | measurementcbo= document.createElement('select'),
|
|---|
| 543 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 544 | <?php
|
|---|
| 545 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 546 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 547 | {
|
|---|
| 548 | ?>
|
|---|
| 549 | measurementcbo.appendChild(
|
|---|
| 550 | option=document.createElement('option'),
|
|---|
| 551 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 552 | option.setAttribute('selected',true),
|
|---|
| 553 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 554 | ),
|
|---|
| 555 | <?php
|
|---|
| 556 | }
|
|---|
| 557 | ?>
|
|---|
| 558 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 559 | );
|
|---|
| 560 | td1.appendChild(
|
|---|
| 561 | button=document.createElement('input'),
|
|---|
| 562 | button.setAttribute('type','button'),
|
|---|
| 563 | button.setAttribute('value','[+]'),
|
|---|
| 564 | button.setAttribute('id','btnAddTime'),
|
|---|
| 565 | button.setAttribute('name','#table1'),
|
|---|
| 566 | button.onclick=function(){
|
|---|
| 567 | var aa;
|
|---|
| 568 | $('div#TableHolder #table1 #Time').each(function(){
|
|---|
| 569 | aa = $(this).val();
|
|---|
| 570 | });
|
|---|
| 571 |
|
|---|
| 572 | 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"); }
|
|---|
| 573 |
|
|---|
| 574 |
|
|---|
| 575 | }
|
|---|
| 576 | );
|
|---|
| 577 | var td2=document.createElement('td');
|
|---|
| 578 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 579 | td2.appendChild(
|
|---|
| 580 | input = document.createElement('input'),
|
|---|
| 581 | input.setAttribute('type','text'),
|
|---|
| 582 | input.setAttribute('id','txtData')
|
|---|
| 583 |
|
|---|
| 584 | );
|
|---|
| 585 | var td4=document.createElement('td');
|
|---|
| 586 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 587 | td4.appendChild(
|
|---|
| 588 | button = document.createElement('input'),
|
|---|
| 589 | button.setAttribute("type",'button'),
|
|---|
| 590 | button.setAttribute('id','btnSplit'),
|
|---|
| 591 | button.setAttribute('value','Split'),
|
|---|
| 592 | button.setAttribute('name','#table1'),
|
|---|
| 593 | button.onclick= function()
|
|---|
| 594 | {
|
|---|
| 595 | var aa;
|
|---|
| 596 | $('div#TableHolder #table1 #Time').each(function(){
|
|---|
| 597 | aa = $(this).val();
|
|---|
| 598 | });
|
|---|
| 599 | if(aa != ""){ var splitting = aa.split(':'); var add = 30;
|
|---|
| 600 |
|
|---|
| 601 | var limit = 60;
|
|---|
| 602 | var adds =0;
|
|---|
| 603 | adds = (Number(splitting[1]) + Number(add));
|
|---|
| 604 | if(adds >= limit){
|
|---|
| 605 | adds = Number(adds) - Number(limit);
|
|---|
| 606 | timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
|
|---|
| 607 |
|
|---|
| 608 | }else{
|
|---|
| 609 |
|
|---|
| 610 | timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
|
|---|
| 611 | }
|
|---|
| 612 | function pad(number, length) {
|
|---|
| 613 |
|
|---|
| 614 | var str = '' + number;
|
|---|
| 615 | while (str.length < length) {
|
|---|
| 616 | str = '0' + str;
|
|---|
| 617 | }
|
|---|
| 618 |
|
|---|
| 619 | return str;
|
|---|
| 620 |
|
|---|
| 621 | }
|
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 | name="name"; value="";
|
|---|
| 625 |
|
|---|
| 626 | meas = "class"; meas2 = "time";
|
|---|
| 627 |
|
|---|
| 628 | getTableId = $(this).attr('name');
|
|---|
| 629 | split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 630 |
|
|---|
| 631 | }
|
|---|
| 632 | );
|
|---|
| 633 | td4.appendChild(
|
|---|
| 634 | button=document.createElement('input'),
|
|---|
| 635 | button.setAttribute('type','button'),
|
|---|
| 636 | button.setAttribute('value','Delete'),
|
|---|
| 637 | button.setAttribute('id','btnDelete'),
|
|---|
| 638 | button.onclick=function(){
|
|---|
| 639 | $('#table1').remove();
|
|---|
| 640 |
|
|---|
| 641 | }
|
|---|
| 642 | );
|
|---|
| 643 |
|
|---|
| 644 | tr.appendChild(td3);
|
|---|
| 645 | tr.appendChild(td1);
|
|---|
| 646 | tr.appendChild(td);
|
|---|
| 647 |
|
|---|
| 648 | tr.appendChild(td2);
|
|---|
| 649 | tr.appendChild(td4);
|
|---|
| 650 | table.appendChild(tr);
|
|---|
| 651 | div.appendChild(table);
|
|---|
| 652 | $('#TableH1').append(div);
|
|---|
| 653 |
|
|---|
| 654 |
|
|---|
| 655 | }
|
|---|
| 656 | var meas;
|
|---|
| 657 | var timeValue;
|
|---|
| 658 | var pad;
|
|---|
| 659 | if(cnt==0){ cnt=2; }
|
|---|
| 660 | function split2()
|
|---|
| 661 | {
|
|---|
| 662 |
|
|---|
| 663 | cnt++;
|
|---|
| 664 | var div= document.createElement("div");
|
|---|
| 665 | div.setAttribute('id','TableHolder');
|
|---|
| 666 | var table = document.createElement("table");
|
|---|
| 667 | table.setAttribute('id',"table"+cnt);
|
|---|
| 668 | table.setAttribute('width','100%');
|
|---|
| 669 | table.setAttribute(name,value);
|
|---|
| 670 | var tr = document.createElement('tr');
|
|---|
| 671 | tr.setAttribute('id','');
|
|---|
| 672 | tr.setAttribute('class','');
|
|---|
| 673 |
|
|---|
| 674 | var td3=document.createElement('td');
|
|---|
| 675 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 676 | td3.setAttribute('class','first');
|
|---|
| 677 |
|
|---|
| 678 | td3.appendChild(
|
|---|
| 679 | input = document.createElement("input"),
|
|---|
| 680 | input.setAttribute("type","time"),
|
|---|
| 681 | input.setAttribute("id","Time"),
|
|---|
| 682 | input.setAttribute("max","24"),
|
|---|
| 683 | input.setAttribute("min","1"),
|
|---|
| 684 | input.setAttribute("required",true),
|
|---|
| 685 | input.setAttribute(meas,meas2),
|
|---|
| 686 | input.setAttribute("value",timeValue)
|
|---|
| 687 |
|
|---|
| 688 |
|
|---|
| 689 | );
|
|---|
| 690 | td3.appendChild(
|
|---|
| 691 | button=document.createElement('input'),
|
|---|
| 692 | button.setAttribute('type','button'),
|
|---|
| 693 | button.setAttribute('value','[+]'),
|
|---|
| 694 | button.setAttribute('id','btnAddTime'),
|
|---|
| 695 | button.setAttribute(meas,meas2),
|
|---|
| 696 | button.setAttribute('name','#table'+cnt),
|
|---|
| 697 |
|
|---|
| 698 | button.onclick=function(){
|
|---|
| 699 | var aa;
|
|---|
| 700 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 701 | aa = $(this).val();
|
|---|
| 702 | });
|
|---|
| 703 | if(aa != ""){var splitting = aa.split(':'); var add = 01;
|
|---|
| 704 |
|
|---|
| 705 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 706 |
|
|---|
| 707 | function pad(number, length) {
|
|---|
| 708 |
|
|---|
| 709 | var str = '' + number;
|
|---|
| 710 | while (str.length < length) {
|
|---|
| 711 | str = '0' + str;
|
|---|
| 712 | }
|
|---|
| 713 |
|
|---|
| 714 | return str;
|
|---|
| 715 |
|
|---|
| 716 | }
|
|---|
| 717 |
|
|---|
| 718 | var s = 0; var get;
|
|---|
| 719 | var nn;
|
|---|
| 720 | nn = $(this).attr('name');
|
|---|
| 721 | $("table").each(function() {
|
|---|
| 722 | if($(this).attr("name")==nn){
|
|---|
| 723 |
|
|---|
| 724 | get = "#"+$(this).attr("id");
|
|---|
| 725 | //get = $(this).attr("name");
|
|---|
| 726 | s =1;
|
|---|
| 727 | }else{
|
|---|
| 728 | if(s==0){
|
|---|
| 729 | get = '#table'+cnt;
|
|---|
| 730 | }
|
|---|
| 731 | }
|
|---|
| 732 | });
|
|---|
| 733 |
|
|---|
| 734 | name="name"; value=$(this).attr('name');
|
|---|
| 735 | meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 736 |
|
|---|
| 737 |
|
|---|
| 738 | }
|
|---|
| 739 | );
|
|---|
| 740 |
|
|---|
| 741 | var td=document.createElement('td');
|
|---|
| 742 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 743 | td.appendChild(
|
|---|
| 744 | sourcecbo= document.createElement('select'),
|
|---|
| 745 | sourcecbo.setAttribute('id','source'),
|
|---|
| 746 | <?php
|
|---|
| 747 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 748 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 749 | {
|
|---|
| 750 | ?>
|
|---|
| 751 | sourcecbo.appendChild(
|
|---|
| 752 | option=document.createElement('option'),
|
|---|
| 753 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 754 | option.setAttribute('selected',true),
|
|---|
| 755 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 756 |
|
|---|
| 757 | ),
|
|---|
| 758 | <?php
|
|---|
| 759 | }
|
|---|
| 760 | ?>
|
|---|
| 761 | sourcecbo.setAttribute('id','source')
|
|---|
| 762 |
|
|---|
| 763 | );
|
|---|
| 764 | var td1=document.createElement('td');
|
|---|
| 765 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 766 | td1.appendChild(
|
|---|
| 767 | measurementcbo= document.createElement('select'),
|
|---|
| 768 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 769 | <?php
|
|---|
| 770 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 771 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 772 | {
|
|---|
| 773 | ?>
|
|---|
| 774 | measurementcbo.appendChild(
|
|---|
| 775 | option=document.createElement('option'),
|
|---|
| 776 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 777 | option.setAttribute('selected',true),
|
|---|
| 778 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 779 | ),
|
|---|
| 780 | <?php
|
|---|
| 781 | }
|
|---|
| 782 | ?>
|
|---|
| 783 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 784 | );
|
|---|
| 785 | td1.appendChild(
|
|---|
| 786 | button=document.createElement('input'),
|
|---|
| 787 | button.setAttribute('type','button'),
|
|---|
| 788 | button.setAttribute('value','[+]'),
|
|---|
| 789 | button.setAttribute('id','btnAddTime'),
|
|---|
| 790 | button.setAttribute('name','#table'+cnt),
|
|---|
| 791 | button.onclick=function(){
|
|---|
| 792 | var aa;
|
|---|
| 793 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 794 | aa = $(this).val();
|
|---|
| 795 | });
|
|---|
| 796 | if(aa != "")
|
|---|
| 797 | {
|
|---|
| 798 | name = "name";
|
|---|
| 799 | value = "#table"+cnt;
|
|---|
| 800 | timeValue = aa;
|
|---|
| 801 | meas = "hidden";
|
|---|
| 802 | meas2 = true;
|
|---|
| 803 | getTableId = $(this).attr('name');
|
|---|
| 804 | split1();
|
|---|
| 805 | }
|
|---|
| 806 | else
|
|---|
| 807 | {
|
|---|
| 808 | alert("please enter value for time to add measurement");
|
|---|
| 809 | }
|
|---|
| 810 |
|
|---|
| 811 |
|
|---|
| 812 | }
|
|---|
| 813 | );
|
|---|
| 814 |
|
|---|
| 815 | var td2=document.createElement('td');
|
|---|
| 816 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 817 | td2.appendChild(
|
|---|
| 818 | input = document.createElement('input'),
|
|---|
| 819 | input.setAttribute('type','text'),
|
|---|
| 820 | input.setAttribute('id','txtData')
|
|---|
| 821 |
|
|---|
| 822 | );
|
|---|
| 823 | var td4=document.createElement('td');
|
|---|
| 824 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 825 | td4.appendChild(
|
|---|
| 826 | button = document.createElement('input'),
|
|---|
| 827 | button.setAttribute("type",'button'),
|
|---|
| 828 | button.setAttribute('id','btnSplit'),
|
|---|
| 829 | button.setAttribute('value','Split'),
|
|---|
| 830 | button.setAttribute('name','#table'+cnt),
|
|---|
| 831 | button.onclick=function(){
|
|---|
| 832 | var aa;
|
|---|
| 833 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 834 | aa = $(this).val();
|
|---|
| 835 | });
|
|---|
| 836 | if(aa != ""){ var splitting = aa.split(':'); var add = 30;
|
|---|
| 837 |
|
|---|
| 838 | var limit = 60;
|
|---|
| 839 | var adds =0;
|
|---|
| 840 | adds = (Number(splitting[1]) + Number(add));
|
|---|
| 841 | if(adds >= limit){
|
|---|
| 842 | adds = Number(adds) - Number(limit);
|
|---|
| 843 | timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
|
|---|
| 844 |
|
|---|
| 845 | }else{
|
|---|
| 846 |
|
|---|
| 847 | timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
|
|---|
| 848 | }
|
|---|
| 849 | function pad(number, length) {
|
|---|
| 850 |
|
|---|
| 851 | var str = '' + number;
|
|---|
| 852 | while (str.length < length) {
|
|---|
| 853 | str = '0' + str;
|
|---|
| 854 | }
|
|---|
| 855 |
|
|---|
| 856 | return str;
|
|---|
| 857 |
|
|---|
| 858 | }
|
|---|
| 859 |
|
|---|
| 860 | meas = "class"; meas2 = "time";
|
|---|
| 861 |
|
|---|
| 862 |
|
|---|
| 863 | getTableId = $(this).attr('name');
|
|---|
| 864 | split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 865 | }
|
|---|
| 866 | );
|
|---|
| 867 | td4.appendChild(
|
|---|
| 868 | button=document.createElement('input'),
|
|---|
| 869 | button.setAttribute('type','button'),
|
|---|
| 870 | button.setAttribute('value','Delete'),
|
|---|
| 871 | button.setAttribute('id','btnDelete'),
|
|---|
| 872 | button.onclick=function(){
|
|---|
| 873 | $('#table'+cnt).remove();
|
|---|
| 874 | cnt--;
|
|---|
| 875 | }
|
|---|
| 876 | );
|
|---|
| 877 |
|
|---|
| 878 | tr.appendChild(td3);
|
|---|
| 879 | tr.appendChild(td1);
|
|---|
| 880 | tr.appendChild(td);
|
|---|
| 881 |
|
|---|
| 882 | tr.appendChild(td2);
|
|---|
| 883 | tr.appendChild(td4);
|
|---|
| 884 | table.appendChild(tr);
|
|---|
| 885 | div.appendChild(table);
|
|---|
| 886 | $(div).insertAfter($(getTableId));
|
|---|
| 887 |
|
|---|
| 888 |
|
|---|
| 889 |
|
|---|
| 890 | }
|
|---|
| 891 | function split1()
|
|---|
| 892 | {
|
|---|
| 893 |
|
|---|
| 894 | cnt++;
|
|---|
| 895 | var div= document.createElement("div");
|
|---|
| 896 | div.setAttribute('id','TableHolder');
|
|---|
| 897 | var table = document.createElement("table");
|
|---|
| 898 | table.setAttribute('id',"table"+cnt);
|
|---|
| 899 | table.setAttribute('width','100%');
|
|---|
| 900 | table.setAttribute(name,value);
|
|---|
| 901 | var tr = document.createElement('tr');
|
|---|
| 902 | tr.setAttribute('id','');
|
|---|
| 903 | tr.setAttribute('class','');
|
|---|
| 904 |
|
|---|
| 905 | var td3=document.createElement('td');
|
|---|
| 906 | td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
|
|---|
| 907 | td3.setAttribute('class','first');
|
|---|
| 908 | td3.appendChild(
|
|---|
| 909 | input = document.createElement("input"),
|
|---|
| 910 | input.setAttribute("type","time"),
|
|---|
| 911 | input.setAttribute("id","Time"),
|
|---|
| 912 | input.setAttribute("max","24"),
|
|---|
| 913 | input.setAttribute("min","1"),
|
|---|
| 914 | input.setAttribute("required",true),
|
|---|
| 915 | input.setAttribute(meas,meas2),
|
|---|
| 916 | input.setAttribute("value",timeValue)
|
|---|
| 917 | );
|
|---|
| 918 | td3.appendChild(
|
|---|
| 919 | button=document.createElement('input'),
|
|---|
| 920 | button.setAttribute('type','button'),
|
|---|
| 921 | button.setAttribute('value','[+]'),
|
|---|
| 922 | button.setAttribute('id','btnAddTime'),
|
|---|
| 923 | button.setAttribute(meas,meas2),
|
|---|
| 924 | button.setAttribute('name','#table'+cnt),
|
|---|
| 925 |
|
|---|
| 926 | button.onclick=function(){
|
|---|
| 927 | var aa;
|
|---|
| 928 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 929 | aa = $(this).val();
|
|---|
| 930 | });
|
|---|
| 931 | if(aa != ""){ var splitting = aa.split(':'); var add = 01;
|
|---|
| 932 |
|
|---|
| 933 | timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
|
|---|
| 934 |
|
|---|
| 935 | function pad(number, length) {
|
|---|
| 936 |
|
|---|
| 937 | var str = '' + number;
|
|---|
| 938 | while (str.length < length) {
|
|---|
| 939 | str = '0' + str;
|
|---|
| 940 | }
|
|---|
| 941 |
|
|---|
| 942 | return str;
|
|---|
| 943 |
|
|---|
| 944 | }
|
|---|
| 945 | var s = 0; var get;
|
|---|
| 946 | var nn;
|
|---|
| 947 | nn = $(this).attr('name');
|
|---|
| 948 | $("table").each(function() {
|
|---|
| 949 | if($(this).attr("name")==nn){
|
|---|
| 950 |
|
|---|
| 951 | get = "#"+$(this).attr("id");
|
|---|
| 952 | //get = $(this).attr("name");
|
|---|
| 953 | s =1;
|
|---|
| 954 | }else{
|
|---|
| 955 | if(s==0){
|
|---|
| 956 | get = '#table'+cnt;
|
|---|
| 957 | }
|
|---|
| 958 | }
|
|---|
| 959 | });
|
|---|
| 960 |
|
|---|
| 961 | name="name"; value=""; meas = "class"; meas2 = "time"; getTableId = get; split1(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 962 |
|
|---|
| 963 |
|
|---|
| 964 | }
|
|---|
| 965 | );
|
|---|
| 966 |
|
|---|
| 967 | var td=document.createElement('td');
|
|---|
| 968 | td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 969 | td.appendChild(
|
|---|
| 970 | sourcecbo= document.createElement('select'),
|
|---|
| 971 | sourcecbo.setAttribute('id','source'),
|
|---|
| 972 | <?php
|
|---|
| 973 | $source=mysql_query("SELECT*FROM source");
|
|---|
| 974 | while($rowsource=mysql_fetch_array($source))
|
|---|
| 975 | {
|
|---|
| 976 | ?>
|
|---|
| 977 | sourcecbo.appendChild(
|
|---|
| 978 | option=document.createElement('option'),
|
|---|
| 979 | option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),
|
|---|
| 980 | option.setAttribute('selected',true),
|
|---|
| 981 | option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>"))
|
|---|
| 982 |
|
|---|
| 983 | ),
|
|---|
| 984 | <?php
|
|---|
| 985 | }
|
|---|
| 986 | ?>
|
|---|
| 987 | sourcecbo.setAttribute('id','source')
|
|---|
| 988 |
|
|---|
| 989 | );
|
|---|
| 990 | var td1=document.createElement('td');
|
|---|
| 991 | td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;");
|
|---|
| 992 |
|
|---|
| 993 | td1.appendChild(
|
|---|
| 994 | measurementcbo= document.createElement('select'),
|
|---|
| 995 | measurementcbo.setAttribute('id','measurement'),
|
|---|
| 996 | <?php
|
|---|
| 997 | $measure=mysql_query("SELECT*FROM measurement");
|
|---|
| 998 | while($rowmeasure=mysql_fetch_array($measure))
|
|---|
| 999 | {
|
|---|
| 1000 | ?>
|
|---|
| 1001 | measurementcbo.appendChild(
|
|---|
| 1002 | option=document.createElement('option'),
|
|---|
| 1003 | option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'),
|
|---|
| 1004 | option.setAttribute('selected',true),
|
|---|
| 1005 | option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>"))
|
|---|
| 1006 | ),
|
|---|
| 1007 | <?php
|
|---|
| 1008 | }
|
|---|
| 1009 | ?>
|
|---|
| 1010 | measurementcbo.setAttribute('id','measurement')
|
|---|
| 1011 | );
|
|---|
| 1012 | td1.appendChild(
|
|---|
| 1013 | button=document.createElement('input'),
|
|---|
| 1014 | button.setAttribute('type','button'),
|
|---|
| 1015 | button.setAttribute('value','[+]'),
|
|---|
| 1016 | button.setAttribute('id','btnAddTime'),
|
|---|
| 1017 | button.setAttribute('name','#table'+cnt),
|
|---|
| 1018 | button.onclick=function(){
|
|---|
| 1019 | var aa;
|
|---|
| 1020 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 1021 | aa = $(this).val();
|
|---|
| 1022 | });
|
|---|
| 1023 | if(aa != ""){ timeValue = aa;
|
|---|
| 1024 | 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"); }
|
|---|
| 1025 |
|
|---|
| 1026 |
|
|---|
| 1027 | }
|
|---|
| 1028 | );
|
|---|
| 1029 |
|
|---|
| 1030 | var td2=document.createElement('td');
|
|---|
| 1031 | td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 1032 | td2.appendChild(
|
|---|
| 1033 | input = document.createElement('input'),
|
|---|
| 1034 | input.setAttribute('type','text'),
|
|---|
| 1035 | input.setAttribute('id','txtData')
|
|---|
| 1036 |
|
|---|
| 1037 | );
|
|---|
| 1038 | var td4=document.createElement('td');
|
|---|
| 1039 | td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;");
|
|---|
| 1040 | td4.appendChild(
|
|---|
| 1041 | button = document.createElement('input'),
|
|---|
| 1042 | button.setAttribute("type",'button'),
|
|---|
| 1043 | button.setAttribute('id','btnSplit'),
|
|---|
| 1044 | button.setAttribute('value','Split'),
|
|---|
| 1045 | button.setAttribute('name','#table'+cnt),
|
|---|
| 1046 | button.onclick=function(){
|
|---|
| 1047 | var aa;
|
|---|
| 1048 | $('div#TableHolder #table'+cnt+' #Time').each(function(){
|
|---|
| 1049 | aa = $(this).val();
|
|---|
| 1050 | });
|
|---|
| 1051 | if(aa != ""){ var splitting = aa.split(':'); var add = 30;
|
|---|
| 1052 |
|
|---|
| 1053 | var limit = 60;
|
|---|
| 1054 | var adds =0;
|
|---|
| 1055 | adds = (Number(splitting[1]) + Number(add));
|
|---|
| 1056 | if(adds >= limit){
|
|---|
| 1057 | adds = Number(adds) - Number(limit);
|
|---|
| 1058 | timeValue =pad(Number(splitting[0])+1,2)+':'+ pad(adds,2);
|
|---|
| 1059 |
|
|---|
| 1060 | }else{
|
|---|
| 1061 |
|
|---|
| 1062 | timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
|
|---|
| 1063 | }
|
|---|
| 1064 | function pad(number, length) {
|
|---|
| 1065 |
|
|---|
| 1066 | var str = '' + number;
|
|---|
| 1067 | while (str.length < length) {
|
|---|
| 1068 | str = '0' + str;
|
|---|
| 1069 | }
|
|---|
| 1070 |
|
|---|
| 1071 | return str;
|
|---|
| 1072 |
|
|---|
| 1073 | }
|
|---|
| 1074 |
|
|---|
| 1075 | meas = "name"; meas2 = "time"; getTableId = $(this).attr('name'); split2(); }else{ alert("please enter value for time to add measurement"); }
|
|---|
| 1076 | }
|
|---|
| 1077 | );
|
|---|
| 1078 | td4.appendChild(
|
|---|
| 1079 | button=document.createElement('input'),
|
|---|
| 1080 | button.setAttribute('type','button'),
|
|---|
| 1081 | button.setAttribute('value','Delete'),
|
|---|
| 1082 | button.setAttribute('id','btnDelete'),
|
|---|
| 1083 | button.onclick=function(){
|
|---|
| 1084 | $('#table'+cnt).remove();
|
|---|
| 1085 | cnt--;
|
|---|
| 1086 | });
|
|---|
| 1087 |
|
|---|
| 1088 | tr.appendChild(td3);
|
|---|
| 1089 | tr.appendChild(td1);
|
|---|
| 1090 | tr.appendChild(td);
|
|---|
| 1091 |
|
|---|
| 1092 | tr.appendChild(td2);
|
|---|
| 1093 | tr.appendChild(td4);
|
|---|
| 1094 | table.appendChild(tr);
|
|---|
| 1095 | div.appendChild(table);
|
|---|
| 1096 | $(div).insertAfter($(getTableId));
|
|---|
| 1097 | }
|
|---|
| 1098 |
|
|---|
| 1099 | });
|
|---|
| 1100 | </script> |
|---|