Changeset 16910
- Timestamp:
- 06/25/13 15:33:50 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/function/SplitDelete.php
r16899 r16910 21 21 } 22 22 $days = Date('Y-m-d',strtotime($day)); 23 $fetch = mysql_query("SELECT * FROM schedule ") or die(mysql_error());23 $fetch = mysql_query("SELECT * FROM schedule ORDER BY fScheduleID ASC") or die(mysql_error()); 24 24 while($rows = mysql_fetch_array($fetch)) 25 25 { … … 33 33 cnt++; 34 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; 35 $('#save').attr('value','UPDATE'); 36 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 75 105 } 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'), 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']; ?>') 119 176 120 option.setAttribute('value','<?php echo $rowsource['fSourceKEY']; ?>'),121 <?php if($rows['fSourceKey'] == $rowsource['fSourceKEY']){ echo"option.setAttribute('selected',true),"; } ?>122 123 177 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 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 201 <?php 202 202 } … … 206 206 if(cnt==0) 207 207 { 208 $('#save').show(); 209 $('#update').hide(); 208 $('#save').attr('value','UPDATE'); 210 209 var div= document.createElement("div"); 211 210 div.setAttribute('id','TableHolder'); … … 568 567 var timeValue; 569 568 var pad; 570 if(cnt==0){ cnt= 2; }569 if(cnt==0){ cnt=1; } 571 570 function split2() 572 571 {
Note:
See TracChangeset
for help on using the changeset viewer.