Changeset 157


Ignore:
Timestamp:
06/22/05 10:20:07 (19 years ago)
Author:
bastiaans
Message:

toga/search.php:

  • Added checks for graph timeperiod

toga/templates/search.tpl:

  • Changed place of error_msg
Location:
trunk/web/addons/toga
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/addons/toga/search.php

    r156 r157  
    55function validateFormInput() {
    66        global $clustername, $tpl, $id, $user, $name, $start_from_time, $start_to_time, $queue;
    7         global $end_from_time, $end_to_time;
     7        global $end_from_time, $end_to_time, $period_start, $period_stop;
    88
    99        $error = 0;
     10        $error_msg = "<FONT COLOR=\"red\"><B>";
     11        $show_msg = 0;
    1012
    1113        $none_set = 0;
     
    1315        if( $id == '' and $user == '' and $name == '' and $start_from_time == '' and $start_to_time == '' and $queue == '' and $end_from_time == '' and $end_to_time == '') {
    1416                $error = 1;
    15                 $error_msg = "<FONT COLOR=\"red\"><B>No search criteria set!</B></FONT>";
     17                $show_msg = 1;
     18                $error_msg .= "No search criteria set!";
    1619        }
    1720
     
    1922
    2023                $error = 1;
    21                 $error_msg = "<FONT COLOR=\"red\"><B>Id must be a number</B></FONT>";
     24                $show_msg = 1;
     25                $error_msg .= "Id must be a number";
    2226        }
    2327
     28        //printf( "period_start = %s period_stop = %s\n", $period_start, $period_stop );
     29
     30        if( !$error and $period_start != '' ) {
     31                //printf( "period_start = %s period_stop = %s\n", $period_start, $period_stop );
     32                $pstart_epoch = datetimeToEpoch( $period_start );
     33                //printf( "period_start = %s period_stop = %s\n", $period_start, $period_stop );
     34                if( $period_stop != '' ) {
     35
     36                        $pstop_epoch = datetimeToEpoch( $period_stop );
     37                        printf( "pstop_epoch = %s pstart_epoch = %s\n", $pstop_epoch, $pstart_epoch );
     38
     39                        if( $pstart_epoch > $pstop_epoch ) {
     40
     41                                $show_msg = 1;
     42                                $error_msg .= "Graph timeperiod reset: start date/time can't be later than end";
     43                                $period_stop = '';
     44                                $period_start = '';
     45                        } else if( $pstop_epoch == $pstart_epoch ) {
     46
     47                                $show_msg = 1;
     48                                $error_msg .= "Graph timeperiod reset: start and end date/time can't be the same";
     49                                $period_stop = '';
     50                                $period_start = '';
     51                        }
     52                }
     53        }
     54
     55        $error_msg .= "</B></FONT>";
    2456        // doe checks en set error en error_msg in case shit
    2557
    26         if( $error) {
     58        if( $show_msg )
    2759                $tpl->assign( "form_error_msg", $error_msg );
    28                 return 0;
    29         } else {
    30                 return 1;
    31         }
     60
     61        return ($error ? 0 : 1 );
    3262}
    3363
     
    108138function datetimeToEpoch( $datetime ) {
    109139
     140        //printf("datetime = %s\n", $datetime );
    110141        $datetime_fields = explode( ' ', $datetime );
    111142
     
    119150        $years = $date_fields[2];
    120151
     152        //printf( "days = %s months = %s years = %s\n", $days, $months, $years );
     153
    121154        $time_fields = explode( ':', $time );
    122155
     
    125158        $seconds = $time_fields[2];
    126159
     160        //printf( "hours = %s minutes = %s seconds = %s\n", $hours, $minutes, $seconds );
     161
    127162        $timestamp = mktime( $hours, $minutes, $seconds, $months, $days, $years );
     163
     164        //printf( "timestamp = %s\n", $timestamp );
    128165
    129166        return $timestamp;
     
    271308                                //printf("start = %s stop = %s\n", $start, $stop );
    272309
    273                                 if( !$period_start ) // Add an additional 5 minutes before
     310                                if( !$period_start ) // Add an extra 10% to graphstart
    274311                                        $period_start = intval( $job_start - (intval( $runningtime * 0.10 ) ) );
    275312                                else
    276313                                        $period_start = datetimeToEpoch( $period_start );
    277314
    278                                 if( !$period_stop ) // Add an additional 5 minutes after
     315                                if( !$period_stop ) // Add an extra 10% to graphend
    279316                                        $period_stop = intval( $job_stop + (intval( $runningtime * 0.10 ) ) );
    280317                                else
  • trunk/web/addons/toga/templates/search.tpl

    r149 r157  
    194194  <TD></TD>
    195195  <TD></TD>
    196   <TD>{form_error_msg}</TD>
     196  <TD></TD>
    197197  <TD>
    198198  <INPUT TYPE="submit" VALUE="Search archive" onClick="setSearchTimestamps();">
     
    202202
    203203</TABLE>
    204 <BR><BR>
     204{form_error_msg}<BR><BR>
    205205<!-- START BLOCK : search_results -->
    206206
Note: See TracChangeset for help on using the changeset viewer.