Changeset 17422 for schedule/js
- Timestamp:
- 01/03/14 09:23:03 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/js/function.js
r16933 r17422 2 2 // June 16, 2013 3 3 4 function GetDate( )4 function GetDate(d,m,y) 5 5 { 6 $('#save').click(function(){ 7 var Time = []; 8 var Data = []; 9 var Source = []; 10 var Measure = []; 11 var Table = []; 12 $('#TableHolder table').each(function(){ // call all the id of the table inside div#TableHolder 13 id=$(this).attr('id'); //Getting all id's 14 Time.push('#'+id+' input#Time'); // Storing id's of each element 15 Data.push('#'+id+' input#txtData'); 16 Source.push('#'+id+' select#source :selected'); 17 Measure.push('#'+id+' select#measurement :selected'); 18 Table.push(id); 19 }); 20 GetSaveData(Time,Data,Source,Measure,Table); // Function call of saving the data 21 }); 22 }; 6 $('document').ready(function(){ 7 /*var currentdate = new Date(); 8 var datetime = currentdate.getFullYear()+ "-"+(currentdate.getMonth()+1) 9 + "-" + (currentdate.getDay()+1); /* + " @ " 10 + currentdate.getHours() + ":" 11 + currentdate.getMinutes() + ":" + currentdate.getSeconds(); */ 12 var Gdate = y+'-'+m+'-'+d; 13 //alert(Gdate); 14 $('#save').click(function(){ 15 if($('#save').val()=='SAVE') 16 { 17 $('.datalisting').each(function(){ 18 var get_seq = 0; 19 get_time = $(this).find(".time").val(); 20 countchild = $(this).find(".tr").length; 21 $(this).find(".tr").each(function(){ 22 23 get_measure = $(this).find(".measure").val(); 24 get_source = $(this).find(".source").val(); 25 get_selected = $(this).find(".selected").val(); 26 GetSaveData(get_time, get_selected, get_source, get_measure, Gdate,get_seq); 27 get_seq++; 28 }); 29 }); 30 } 31 else 32 { 33 GetDelete(Gdate); 34 $('.datalisting').each(function(){ 35 var get_seq = 0; 36 get_time = $(this).find(".time").val(); 37 countchild = $(this).find(".tr").length; 38 $(this).find(".tr").each(function(){ 39 40 get_measure = $(this).find(".measure").val(); 41 get_source = $(this).find(".source").val(); 42 get_selected = $(this).find(".selected").val(); 43 GetUpdateData(get_time, get_selected, get_source, get_measure, Gdate,get_seq); 44 get_seq++; 45 }); 46 }); 47 } 48 }); 23 49 24 50 25 function GetSaveData(Time,Data,Source,Measure,Table){26 var checks=0;27 TimeSave = [];28 DataSave = [];29 SourceSave = [];30 MeasureSave = [];31 for(i=0;i<Table.length;i++)32 {33 $(Time[i]).each(function(){34 TimeSave.push($(this).val()); // extracting each data into a value35 });36 $(Data[i]).each(function(){37 DataSave.push($(this).val()); // extracting each data into a value38 });39 $(Source[i]).each(function(){40 SourceSave.push($(this).val()); // extracting each data into a value41 });42 $(Measure[i]).each(function(){43 MeasureSave.push($(this).val()); // extracting each data into a value44 });45 }46 if($('#save').val()=='UPDATE')47 {48 if(checks == 0)49 {50 $.ajax({51 type: "POST",52 cache: false,53 url: "Transaction/update.php",54 data: "Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day, //posting the data to save55 success: function(data) {56 57 alert('Successfully Updated ! '+year+'-'+month+'-'+day);58 59 }60 });61 }62 else63 {64 51 65 alert("Please fill all the details!"); 66 } 67 } 68 else 69 { 70 if(checks == 0) 71 { 52 function GetSaveData(Time,Data,Source,Measure,date,seq){ 53 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data); 72 54 $.ajax({ 73 55 type: "POST", 74 56 cache: false, 75 57 url: "Transaction/insert.php", 76 data: " Time="+TimeSave+'&Source='+SourceSave+'&measure='+MeasureSave+'&Data='+DataSave+'&Date='+year+'-'+month+'-'+day, //posting the data to save58 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save 77 59 success: function(data) { 78 79 alert('Successfully added ! '+year+'-'+month+'-'+day);60 alert('Successfully added ! '+date); 61 //$("#Data").append("Ok"+date); 80 62 81 63 } 82 64 }); 83 } 84 else 85 { 86 87 alert("Please fill all the details!"); 88 } 89 90 } 91 65 }; 66 function GetDelete(date){ 67 //alert('del'); 68 $.ajax({ 69 type:"POST", 70 cache:false, 71 url:"Transaction/delete.php", 72 data:"Gdate="+date, 73 success:function(data){ 74 75 } 76 }); 77 }; 78 function GetUpdateData(Time,Data,Source,Measure,date,seq){ 79 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data); 80 $.ajax({ 81 type: "POST", 82 cache: false, 83 url: "Transaction/update.php", 84 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save 85 success: function(data) { 86 alert('Successfully added ! '+date); 87 //$("#Data").append("Ok"+date); 88 89 } 90 }); 91 }; 92 }); 92 93 };
Note:
See TracChangeset
for help on using the changeset viewer.