Changeset 16721 for schedule/function


Ignore:
Timestamp:
06/05/13 05:45:07 (11 years ago)
Author:
tanio
Message:
 
Location:
schedule/function
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • schedule/function/SplitDelete.php

    r16608 r16721  
    11<script type="text/javascript">
    22 $(document).ready(function(){
     3 
    34 var timeValue;
    45var meas;
    56var meas2;
    67var 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 
    850        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");
    9225                table.setAttribute('id',"table2");
    10226                table.setAttribute('width','100%');
    11227        var tr = document.createElement('tr');
     228                tr.setAttribute('id','');
     229                tr.setAttribute('class','');
    12230        var td3=document.createElement('td');
    13231                td3.setAttribute('style','border:1px solid white; color:#37DFB1; font-size:14px; text-align:center;');
     
    19237                                        input.setAttribute("min","1"),
    20238                                        input.setAttribute("required",true)
    21                                
    22239                );
    23240                        td3.appendChild(
     
    27244                        button.setAttribute('id','btnAddTime'),
    28245                        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;   
    33247
    34248                        timeValue = pad((Number(splitting[0]) + Number(add)),2)+':'+splitting[1];
     
    43257                                                return str;
    44258
    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");   }
    48260
    49261                               
     
    56268                                sourcecbo.setAttribute('id','source1'),
    57269<?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?>                             
    62274                                sourcecbo.appendChild(
    63275                                        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 ?>
    75284                        sourcecbo.setAttribute('id','source1')
    76285                                       
     
    103312                        button.setAttribute('id','btnAddTime'),
    104313                        button.onclick=function(){
    105                         if($('#Time1').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");   }
    106315
    107316                               
     
    114323                        input.setAttribute('type','text'),
    115324                        input.setAttribute('id','txtData1')
    116                        
    117325                       
    118326                );
     
    126334                        button.onclick= function()
    127335                        {
    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;   
    131337
    132338                        timeValue =pad(splitting[0],2)+':'+ pad((Number(splitting[1]) + Number(add)),2);
     
    141347                                                return str;
    142348
    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");   }
    147352                                 
    148                                
    149353                        }
    150354                );
     
    155359                        button.setAttribute('id','btnDelete'),
    156360                        button.onclick=function(){
    157                                 $('#table2').remove();
    158                         }
    159                 );
    160                
     361                                $('#table1').remove();
     362
     363                        }
     364                );
     365       
    161366                tr.appendChild(td3);
    162367                tr.appendChild(td1);
     
    166371                tr.appendChild(td4);
    167372                table.appendChild(tr);
    168        
     373               
    169374                $('#TableH1').append(table);
    170        
    171                
    172375               
    173376        var table = document.createElement("table");
     
    323526                $('#TableH1').append(table);
    324527               
    325                 var meas;
     528               
     529        }
     530        var meas;
    326531                var timeValue;
    327532                var pad;
    328        
     533        if(cnt==0){  cnt=2; }   
    329534        function split()
    330535        {
  • schedule/function/function.php

    r16688 r16721  
    1212        $(document).ready(function GetDate(){
    1313         // for fupdate
    14          
    15          
    16        
    17          
    18        
    19        
    2014        <?php
    2115       
     
    2721        ?>
    2822        $('#save').click(function(){
    29 
    30 
     23var dtr;
     24                 dtr = '<?php echo $_GET['days'];  ?>';
     25                        //alert(dtr);
    3126                var InputValue = [];
    3227                var selectedSource = [];
     
    5853               
    5954                if(checks == 0){
    60                 window.location = 'Transaction/insert.php?Time='+selectedTime+'&Source='+selectedSource+'&measure='+selectedMeasurement+'&Data='+InputValue+'&Date='+day+'-'+month+'-'+year;
     55                window.location = 'Transaction/insert.php?Time='+selectedTime+'&Source='+selectedSource+'&measure='+selectedMeasurement+'&Data='+InputValue+'&Date='+dtr;
    6156        }else{
    6257       
Note: See TracChangeset for help on using the changeset viewer.