Changeset 16721 for schedule/function/SplitDelete.php
- Timestamp:
- 06/05/13 05:45:07 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/function/SplitDelete.php
r16608 r16721 1 1 <script type="text/javascript"> 2 2 $(document).ready(function(){ 3 3 4 var timeValue; 4 5 var meas; 5 6 var meas2; 6 7 var getTableId; 7 window.cnt=2; 8 window.cnt=0; 9 10 11 12 13 //-------------------------------- fetch----------------------------// 14 15 16 17 //-----------------------------------------------// 18 //end fetch 19 20 //------------------------------------------------// 21 var x = 0; 22 23 <?php 24 25 26 include '../include/factdb.php'; 27 $day = $_GET['days']; 28 $days = Date('Y-m-d',strtotime($day)); 29 ?> 30 //alert('<?php echo $day; ?>'); 31 32 <?php 33 34 35 $fetch = mysql_query("SELECT * FROM schedule") or die(mysql_error()); 36 37 while($rows = mysql_fetch_array($fetch)){ 38 $timestamp=strtotime($rows['fLastUpdate']); 39 $timestamp2 = date('Y-m-d',$timestamp); 40 $date_time = date('H:i',$timestamp); 41 //$time_new = $date_time->format('H:i:s') 42 if($days == $timestamp2){ 43 44 45 ?> 46 cnt++; 47 48 49 8 50 var table = document.createElement("table"); 51 table.setAttribute('id',"table"+cnt); 52 table.setAttribute('width','100%'); 53 var tr = document.createElement('tr'); 54 var td3=document.createElement('td'); 55 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;'); 56 td3.appendChild( 57 input = document.createElement("input"), 58 input.setAttribute("type","time"), 59 input.setAttribute("id","Time"+cnt), 60 input.setAttribute("max","24"), 61 input.setAttribute("min","1"), 62 input.setAttribute("required",true), 63 input.setAttribute("value",'<?php echo $date_time; ?>') 64 65 ); 66 td3.appendChild( 67 button=document.createElement('input'), 68 button.setAttribute('type','button'), 69 button.setAttribute('value','[+]'), 70 button.setAttribute('id','btnAddTime'), 71 button.onclick=function(){ 72 73 74 75 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 01; 76 77 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; 78 79 function pad(number, length) { 80 81 var str = '' + number; 82 while (str.length < length) { 83 str = '0' + str; 84 } 85 86 return str; 87 88 } 89 90 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); } 91 92 93 } 94 ); 95 var td=document.createElement('td'); 96 td.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;"); 97 td.appendChild( 98 sourcecbo= document.createElement('select'), 99 sourcecbo.setAttribute('id','source'+cnt), 100 <?php 101 $source=mysql_query("SELECT*FROM source"); 102 while($rowsource=mysql_fetch_array($source)) 103 { 104 ?> 105 sourcecbo.appendChild( 106 option=document.createElement('option'), 107 108 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 109 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?> 110 111 112 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 113 114 115 ), 116 <?php 117 } 118 ?> 119 sourcecbo.setAttribute('id','source'+cnt) 120 121 ); 122 var td1=document.createElement('td'); 123 td1.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px;text-align:center;"); 124 td1.appendChild( 125 measurementcbo= document.createElement('select'), 126 measurementcbo.setAttribute('id','measurement'+cnt), 127 <?php 128 $measure=mysql_query("SELECT*FROM measurement"); 129 while($rowmeasure=mysql_fetch_array($measure)) 130 { 131 ?> 132 measurementcbo.appendChild( 133 option=document.createElement('option'), 134 option.setAttribute('value','<?php echo $rowmeasure['fMeasurementKey']; ?>'), 135 136 <?php if($rows['fMeasurementTypeKey']==$rowmeasure['fMeasurementKey']){ echo "option.setAttribute('selected',true),";} ?> 137 138 option.appendChild(document.createTextNode("<?php echo $rowmeasure['fMeasurement']; ?>")) 139 ), 140 <?php 141 } 142 ?> 143 measurementcbo.setAttribute('id','measurement'+cnt) 144 ); 145 td1.appendChild( 146 button=document.createElement('input'), 147 button.setAttribute('type','button'), 148 button.setAttribute('value','[+]'), 149 button.setAttribute('id','btnAddTime'), 150 button.onclick=function(){ 151 if($('#Time1').val() != ""){ timeValue = $('#Time1').val(); meas = "hidden"; meas2 = true; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); } 152 153 154 } 155 ); 156 var td2=document.createElement('td'); 157 td2.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;"); 158 td2.appendChild( 159 input = document.createElement('input'), 160 input.setAttribute('type','text'), 161 input.setAttribute('id','txtData'+cnt), 162 input.setAttribute('value','<?php echo $rows['fData']; ?>') 163 164 165 ); 166 var td4=document.createElement('td'); 167 td4.setAttribute("style","border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;"); 168 td4.appendChild( 169 button = document.createElement('input'), 170 button.setAttribute("type",'button'), 171 button.setAttribute('id','btnSplit'), 172 button.setAttribute('value','Split'), 173 button.onclick= function() 174 { 175 176 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 30; 177 178 179 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); 180 181 function pad(number, length) { 182 183 var str = '' + number; 184 while (str.length < length) { 185 str = '0' + str; 186 } 187 188 return str; 189 190 }; 191 192 meas = "name"; meas2 = "time"; getTableId = '#table'+cnt; split1(); }else{ alert("please enter value for time to add measurement"); } 193 194 195 196 } 197 ); 198 td4.appendChild( 199 button=document.createElement('input'), 200 button.setAttribute('type','button'), 201 button.setAttribute('value','Delete'), 202 button.setAttribute('id','btnDelete'), 203 button.onclick=function(){ 204 $('#table'+cnt).remove(); 205 } 206 ); 207 208 tr.appendChild(td3); 209 tr.appendChild(td1); 210 tr.appendChild(td); 211 212 tr.appendChild(td2); 213 tr.appendChild(td4); 214 table.appendChild(tr); 215 216 $('#TableH1').append(table); 217 218 <?php 219 } 220 } 221 ?> 222 223 if(cnt==0){ 224 var table = document.createElement("table"); 9 225 table.setAttribute('id',"table2"); 10 226 table.setAttribute('width','100%'); 11 227 var tr = document.createElement('tr'); 228 tr.setAttribute('id',''); 229 tr.setAttribute('class',''); 12 230 var td3=document.createElement('td'); 13 231 td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;'); … … 19 237 input.setAttribute("min","1"), 20 238 input.setAttribute("required",true) 21 22 239 ); 23 240 td3.appendChild( … … 27 244 button.setAttribute('id','btnAddTime'), 28 245 button.onclick=function(){ 29 30 31 32 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 01; 246 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 01; 33 247 34 248 timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1]; … … 43 257 return str; 44 258 45 } 46 47 meas = "name"; meas2 = "time"; getTableId = '#table2'; split1(); }else{ alert("please enter value for time to add measurement"); } 259 }; meas = "name"; meas2 = "time"; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); } 48 260 49 261 … … 56 268 sourcecbo.setAttribute('id','source1'), 57 269 <?php 58 $source=mysql_query("SELECT*FROM source");59 while($rowsource=mysql_fetch_array($source))60 {61 ?> 270 $source=mysql_query("SELECT*FROM source"); 271 while($rowsource=mysql_fetch_array($source)) 272 { 273 ?> 62 274 sourcecbo.appendChild( 63 275 option=document.createElement('option'), 64 65 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 66 option.setAttribute('selected',true), 67 68 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 69 70 71 ), 72 <?php 73 } 74 ?> 276 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'), 277 option.setAttribute('selected',true), 278 option.appendChild(document.createTextNode("<?php echo $rowsource['fSourceName']; ?>")) 279 280 ), 281 <?php 282 } 283 ?> 75 284 sourcecbo.setAttribute('id','source1') 76 285 … … 103 312 button.setAttribute('id','btnAddTime'), 104 313 button.onclick=function(){ 105 if($('#Time 1').val() != ""){ timeValue = $('#Time1').val(); meas = "hidden"; meas2 = true; getTableId = '#table2'; split1(); }else{ alert("please enter value for time to add measurement"); }314 if($('#Time2').val() != ""){ timeValue = $('#Time2').val(); meas = "hidden"; meas2 = true; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); } 106 315 107 316 … … 114 323 input.setAttribute('type','text'), 115 324 input.setAttribute('id','txtData1') 116 117 325 118 326 ); … … 126 334 button.onclick= function() 127 335 { 128 129 if($('#Time1').val() != ""){ var splitting = $('#Time1').val().split(':'); var add = 30; 130 336 if($('#Time2').val() != ""){ var splitting = $('#Time2').val().split(':'); var add = 30; 131 337 132 338 timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2); … … 141 347 return str; 142 348 143 }; 144 145 meas = "name"; meas2 = "time"; getTableId = '#table2'; split1(); }else{ alert("please enter value for time to add measurement"); } 146 349 } 350 351 meas = "name"; meas2 = "time"; getTableId = '#table1'; split(); }else{ alert("please enter value for time to add measurement"); } 147 352 148 149 353 } 150 354 ); … … 155 359 button.setAttribute('id','btnDelete'), 156 360 button.onclick=function(){ 157 $('#table2').remove(); 158 } 159 ); 160 361 $('#table1').remove(); 362 363 } 364 ); 365 161 366 tr.appendChild(td3); 162 367 tr.appendChild(td1); … … 166 371 tr.appendChild(td4); 167 372 table.appendChild(tr); 168 373 169 374 $('#TableH1').append(table); 170 171 172 375 173 376 var table = document.createElement("table"); … … 323 526 $('#TableH1').append(table); 324 527 325 var meas; 528 529 } 530 var meas; 326 531 var timeValue; 327 532 var pad; 328 533 if(cnt==0){ cnt=2; } 329 534 function split() 330 535 {
Note:
See TracChangeset
for help on using the changeset viewer.