Changeset 1664

Show
Ignore:
Timestamp:
03/02/10 14:06:22 (5 months ago)
Author:
thomas
Message:

ullTime: display current working time

Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/ullTimePlugin/lib/model/doctrine/PluginUllTimeReporting.class.php

    r1142 r1664  
    66abstract class PluginUllTimeReporting extends BaseUllTimeReporting 
    77{ 
    8    
     8 
    99  /** 
    1010   * pre save hook 
    11    *  
     11   * 
    1212   * auto calculate totals 
    1313   * 
     
    1717  { 
    1818    $this->total_break_seconds = 0; 
    19      
     19 
    2020    if ($this->begin_break1_at && $this->end_break1_at) 
    2121    { 
    2222      $this->total_break_seconds += strtotime($this->end_break1_at) - strtotime($this->begin_break1_at); 
    2323    } 
    24      
     24 
    2525    if ($this->begin_break2_at && $this->end_break2_at) 
    2626    { 
    2727      $this->total_break_seconds += strtotime($this->end_break2_at) - strtotime($this->begin_break2_at); 
    28     }     
    29      
     28    } 
     29 
    3030    if ($this->begin_break3_at && $this->end_break3_at) 
    3131    { 
     
    3636    { 
    3737      $this->total_work_seconds = strtotime($this->end_work_at) - strtotime($this->begin_work_at) - $this->total_break_seconds; 
    38     }    
    39   }   
     38    } 
     39  } 
     40 
     41  public function getBreakDuration($breakNum) 
     42  { 
     43    $beginField = 'begin_break' . $breakNum . '_at'; 
     44    $endField = 'end_break' . $breakNum . '_at'; 
     45    if ($this[$beginField] && $this[$endField]) 
     46    { 
     47      return strtotime($this[$endField]) - strtotime($this[$beginField]); 
     48    } 
     49    else 
     50    { 
     51      return 0; 
     52    } 
     53  } 
    4054 
    4155} 
  • trunk/plugins/ullTimePlugin/modules/ullTime/lib/BaseUllTimeActions.class.php

    r1646 r1664  
    163163    $this->addGlobalValidators(); 
    164164     
    165     $this->sum_time = UllTimeReportingTable::findTotalWorkSecondsByDateAndUserId($request->getParameter('date'), $this->user_id); 
    166     $this->is_today = ($request->getParameter('date') == date("Y-m-d",time())); 
     165    //$this->sum_time = UllTimeReportingTable::findTotalWorkSecondsByDateAndUserId($request->getParameter('date'), $this->user_id); 
     166    //$this->is_today = ($request->getParameter('date') == date("Y-m-d",time())); 
     167    $this->break_1_duration = $this->doc->getBreakDuration(1); 
     168    $this->break_2_duration = $this->doc->getBreakDuration(2); 
     169    $this->break_3_duration = $this->doc->getBreakDuration(3); 
    167170    $this->up_to_now = strtotime(date("H:i",time())) - strtotime($this->doc->begin_work_at) - $this->doc->total_break_seconds; 
     171     
     172    $sumTime = UllTimeReportingTable::findTotalWorkSecondsByDateAndUserId($request->getParameter('date'), $this->user_id); 
     173    if (($request->getParameter('date') != date("Y-m-d",time())) || !$this->doc->begin_work_at) 
     174    { 
     175      $this->up_to_now = 0; 
     176    } 
     177     
     178    if($sumTime > 0) 
     179    { 
     180      $this->up_to_now = $sumTime; 
     181    } 
    168182     
    169183    $this->breadcrumbForEdit(); 
  • trunk/plugins/ullTimePlugin/modules/ullTime/templates/editSuccess.php

    r1608 r1664  
    22 
    33<?php include_partial('ullTableTool/flash', array('name' => 'message')) ?> 
     4<?php $timeDurationWidget = new ullWidgetTimeDurationRead(); ?> 
    45 
    56<h3> 
     
    1516<div class="edit_container"> 
    1617<table class="edit_table ull_time_edit_table_worktime"> 
     18 
     19        <col class="col_edit_list_name"/> 
     20        <col class="col_edit_list_begin"/> 
     21        <col class="col_edit_list_end"/> 
     22        <col class="col_edit_list_sum"/> 
     23         
    1724  <thead> 
    1825    <tr class="color_dark_bg"> 
     
    2027      <th class="color_dark_bg"><?php echo __('Begin', null, 'common') ?></th> 
    2128      <th class="color_dark_bg"><?php echo __('End', null, 'common') ?></th> 
     29      <th class="color_dark_bg"><?php echo __('Total', null, 'common') ?></th> 
    2230    </tr> 
    2331  </thead> 
     
    3442        <?php echo $generator->getForm()->offsetGet('end_work_at')->renderError() ?> 
    3543      </td> 
     44      <td> 
     45        <?php echo $timeDurationWidget->render(null, $up_to_now); ?> 
     46      </td> 
    3647    </tr> 
    3748     
     
    3950</table> 
    4051 
     52 
    4153<table class="edit_table"> 
     54         
     55        <col class="col_edit_list_name"/> 
     56        <col class="col_edit_list_begin"/> 
     57        <col class="col_edit_list_end"/> 
     58        <col class="col_edit_list_sum"/> 
     59         
    4260  <thead> 
    4361    <tr class="color_dark_bg"> 
     
    4563      <th class="color_dark_bg"><?php echo __('Begin', null, 'common') ?></th> 
    4664      <th class="color_dark_bg"><?php echo __('End', null, 'common') ?></th> 
     65      <th class="color_dark_bg"><?php echo __('Total', null, 'common') ?></th> 
    4766    </tr> 
    4867  </thead> 
     
    5978        <?php echo $generator->getForm()->offsetGet('end_break1_at')->renderError() ?> 
    6079      </td> 
     80      <td> 
     81        <?php echo $timeDurationWidget->render(null, $break_1_duration); ?> 
     82      </td> 
    6183    </tr>    
    6284    <tr> 
     
    7092        <?php echo $generator->getForm()->offsetGet('end_break2_at')->renderError() ?> 
    7193      </td> 
     94      <td> 
     95        <?php echo $timeDurationWidget->render(null, $break_2_duration); ?> 
     96      </td> 
    7297    </tr>        
    7398    <tr> 
     
    80105        <?php echo $generator->getForm()->offsetGet('end_break3_at')->render() ?> 
    81106        <?php echo $generator->getForm()->offsetGet('end_break3_at')->renderError() ?> 
     107      </td> 
     108      <td> 
     109        <?php echo $timeDurationWidget->render(null, $break_3_duration); ?> 
    82110      </td> 
    83111    </tr>       
  • trunk/plugins/ullTimeThemeNGPlugin/web/css/main.css

    r1649 r1664  
    8181 
    8282/* Make the time duration columns as thin as possible to make alignment to the right looking good */ 
    83 .col_duration_seconds_header, .col_period_list_time_total, .col_period_list_project_total, .col_period_list_delta { 
     83.col_duration_seconds_header, .col_period_list_time_total, .col_period_list_project_total, .col_period_list_delta, .col_edit_list_sum { 
    8484        width: 1em; 
    8585} 
  • trunk/test/unit/ullTimePlugin/UllTimeReportingTest.php

    r1142 r1664  
    1010sfContext::createInstance($configuration); 
    1111 
    12 $t = new myTestCase(2, new lime_output_color, $configuration); 
     12$t = new myTestCase(5, new lime_output_color, $configuration); 
    1313$path = dirname(__FILE__); 
    1414$t->setFixturesPath($path); 
     
    3232  $t->is($report->total_work_seconds, 28800, 'Generates the correct work total'); 
    3333  $t->is($report->total_break_seconds, 1800, 'Generates the correct break total'); 
     34 
     35$t->diag('getBreakSum()'); 
     36  $report = new UllTimeReporting; 
     37  $report->UllUser        = $user; 
     38  $report->date           = '2009-09-18'; 
     39  $report->begin_work_at  = '08:30:00'; 
     40  $report->end_work_at    = '17:00:00'; 
     41  $report->begin_break1_at = '10:00:00'; 
     42  $report->end_break1_at  = '10:10:00'; 
     43  $report->begin_break2_at = '12:40:00'; 
    3444   
     45  $report->save(); 
     46  $t->is($report->getBreakDuration(1), 600, 'Returns the correct break1 seconds'); 
     47  $t->is($report->getBreakDuration(2), 0, 'Returns zero for empty end time'); 
     48  $t->is($report->getBreakDuration(3), 0, 'Returns zero for empty begin and end time'); 
     49   
     50