Changeset 17552
- Timestamp:
- 02/13/14 18:12:43 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
schedule/js/function.js
r17545 r17552 1 1 'use strict'; 2 // This module prepare by : Jaypee Tanio 3 // June 16, 2013 2 /** 3 Created by: Jaypee Tanio 4 Date Created: Jun 16, 2013 5 Modified by: Ella Tose 6 Last Modified: Feb 14, 2014 7 */ 8 4 9 5 10 var currentDate; 6 var transCount;7 var transLoadPrev;8 var Gdate;9 var transPrevNight;10 11 11 12 function GetDate(d,m,y) 12 13 { 13 currentDate = y+'-'+m+'-'+d; 14 transCount = 1; 15 transLoadPrev = 1; 16 transPrevNight = 1; 17 $('document').ready(function(){ 18 $('#save').click(function(){ 19 if(($('#save').val()=='SAVE') && transCount==1) 20 { 21 transCount = 0; 22 Gdate = currentDate; 23 alert("Save: " + Gdate); 24 $('.datalisting').each(function(){ 25 var get_seq = 0; 26 var get_time = $(this).find(".time").val(); 27 var countchild = $(this).find(".tr").length; 28 $(this).find(".tr").each(function(){ 29 var get_measure = $(this).find(".measure").val(); 30 var get_source = $(this).find(".source").val(); 31 var get_selected = $(this).find(".selected").val(); 32 GetSaveData(get_time, get_selected, get_source, get_measure, Gdate,get_seq); 33 get_seq++; 34 }); 35 }); 36 } 37 else if(($('#save').val()=='UPDATE') && transCount==1) 38 { 39 transCount = 0; 40 Gdate = currentDate; 41 alert("Update: " + Gdate); 42 GetDelete(Gdate); 43 $('.datalisting').each(function(){ 44 var get_seq = 0; 45 var get_time = $(this).find(".time").val(); 46 var countchild = $(this).find(".tr").length; 47 $(this).find(".tr").each(function(){ 48 49 var get_measure = $(this).find(".measure").val(); 50 var get_source = $(this).find(".source").val(); 51 var get_selected = $(this).find(".selected").val(); 52 GetUpdateData(get_time, get_selected, get_source, get_measure, Gdate, get_seq); 53 get_seq++; 54 }); 55 }); 56 } 57 14 currentDate = y+'-'+m+'-'+d; 15 }; 16 17 $('document').ready(function() { 18 $('#LoadPrev').click(function() { 19 $.ajax({ 20 type:"POST", 21 cache: false, 22 url: "Transaction/PreviousData.php", 23 data: "SelectedDay="+currentDate, 24 success: function(data) { 25 var obj = $.parseJSON(data); 26 $('#Scheduling').load('Module/Scheduling.php?days='+obj+'&prev=true'); 27 } 28 }); 58 29 }); 59 30 60 function GetSaveData(Time,Data,Source,Measure,date,seq){ 61 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data); 62 $.ajax({ 63 type: "POST", 64 cache: false, 65 url: "Transaction/insert.php", 66 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save 67 success: function(data) { 68 alert('Successfully added ! '+date); 69 //$("#Data").append("Ok"+date); 70 71 } 72 }); 73 }; 74 function GetDelete(date){ 75 //alert('del'); 76 $.ajax({ 77 type:"POST", 78 cache:false, 79 url:"Transaction/delete.php", 80 data:"Gdate="+date, 81 success:function(data){ 82 83 } 84 }); 85 }; 86 function GetUpdateData(Time,Data,Source,Measure,date,seq){ 87 //alert("Time:"+Time+" | Measure:"+Measure +" | Source:"+Source+" | Data:"+Data); 88 $.ajax({ 89 type: "POST", 90 cache: false, 91 url: "Transaction/update.php", 92 data: "GTime="+Time+'&Source='+Source+'&measure='+Measure+'&Data='+Data+'&GDate='+date+'&seq='+seq, //posting the data to save 93 success: function(data) { 94 alert('Successfully added ! '+date); 95 //$("#Data").append("Ok"+date); 96 97 } 98 }); 99 }; 100 }); 31 $('#save').click(function(){ 32 var Gdate = currentDate; 33 var data = new Array(); 34 var count = 0; 35 $('.datalisting').each(function() { 36 var get_seq = 0; 37 var get_time = $(this).find(".time").val(); 38 var countchild = $(this).find(".tr").length; 39 data[count] = new Array(); 40 $(this).find(".tr").each(function() { 41 var get_measure = $(this).find(".measure").val(); 42 var get_source = $(this).find(".source").val(); 43 var get_selected = $(this).find(".selected").val(); 44 if(get_source != null && get_source != null && get_selected != null) { 45 data[count][get_seq] = new Array(); 46 data[count][get_seq].push(get_time); 47 data[count][get_seq].push(get_seq); 48 data[count][get_seq].push(get_selected); 49 data[count][get_seq].push(get_source); 50 data[count][get_seq].push(get_measure); 51 get_seq++; 52 } 53 }); 54 if(get_time != null) { 55 count++; 56 } 57 }); 58 if($('#save').val()=='SAVE') 59 { 60 SaveData(data, Gdate, "save"); 61 } 62 else { 63 SaveData(data, Gdate, "update"); 64 } 65 }); 66 }); 67 68 function SaveData(data, date, trans) { 69 $.ajax({ 70 type:"POST", 71 cache: false, 72 url: "Transaction/saveSchedule.php", 73 data: "Data="+JSON.stringify(data)+"&Date="+date, 74 success: function(result) { 75 if(trans == "save") { 76 alert("New schedule successfully saved."); 77 } else { 78 alert("Schedule successfully updated."); 79 } 80 } 81 }); 101 82 };
Note:
See TracChangeset
for help on using the changeset viewer.