Changeset 487

Show
Ignore:
Timestamp:
01/24/07 21:33:06 (2 years ago)
Author:
jarmo
Message:
  • Merged changesets [463] - [486] to the workorder_report_rename branch.
  • Continued the renaming process.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/workorder_report_rename/app/controllers/action_key_controller.rb

    r464 r487  
    1111class ActionKeyController < ApplicationController 
    1212  prepend_before_filter :login_required 
    13   layout 'mainlevel' 
    1413 
    1514  def list 
    1615    @title = _('Keys') 
    17     @fields = [['Name (controller/action)', :name], ['Information', :info]] 
    18     @items = items_for_page(ActionKey, :order => 'name'
     16    @fields = [['Name (controller/action)', :name, 'name'], ['Information', :info, 'info']] 
     17    @items = items_for_page(ActionKey
    1918    render(:partial => 'shared/list_items', :layout => 'mainlevel') 
    2019  end 
  • branches/workorder_report_rename/app/controllers/application.rb

    r469 r487  
    2020  init_gettext 'norfello_cmms' 
    2121 
    22   model :user 
    2322  layout 'mainlevel' 
    2423  before_filter :set_current_user, :set_selected_asset, :prepare_tree_view, :protect_page_groups, :handle_cancel_submit 
     
    119118  def set_current_user 
    120119    # Possibly hijacked session 
    121     if session[:user_ip] and session[:user_ip] != @request.remote_ip 
    122       info "Request from different ip than login! Login: #{session[:user_ip]}, request: #{@request.remote_ip}" 
     120    if session[:user_ip] and session[:user_ip] != request.remote_ip 
     121      info "Request from different ip than login! Login: #{session[:user_ip]}, request: #{request.remote_ip}" 
    123122      reset_session 
    124123      redirect_to :controller => 'user', :action => 'logout' 
     
    141140    #raise session[:user].lang 
    142141    login = session[:user].login if session[:user] 
    143     ActiveRecord::Base.logged_information(login, @request.remote_ip) 
    144     @message_count = session[:user].received_messages.count("unread = '1'") 
     142    ActiveRecord::Base.logged_information(login, request.remote_ip) 
     143    @message_count = session[:user].received_messages.count(:conditions => "unread = '1'") 
    145144    @message_id = session[:user].received_messages.find(:first, :conditions => "unread = '1'").id if @message_count == 1 
    146145    GetText.locale = session[:user].lang 
     
    310309    # Forms 
    311310    output = text.gsub(/#{form_url_match}\/#{params_match}/) { |m| "[#{$~[1]}]" } 
    312     # Work order
     311    # Task
    313312    output = output.gsub(/#{task_url_match}\/#{params_match}/) { |m| "{#{$~[1]}}" } 
    314313    # Attachments 
     
    450449    @items_limit ||= 20 
    451450    @items_offset ||= (params[:items_offset].to_i || 0) 
     451    sort_sql = (@fields.collect { |f| f[2] })[params[:sort_column].to_i] if @fields and params[:sort_column] 
     452    sort_sql += ' DESC' if sort_sql and params[:sort_desc] 
     453    @sort_column = params[:sort_column].to_i if params[:sort_column] 
     454    @sort_desc = 1 if params[:sort_desc] 
    452455    finder_method = options[:finder_method] || :find 
    453456    options.delete(:finder_method) # So that it won't get passed to the find 
    454     return finder.send(finder_method, :all, {:readonly => true, :limit => @items_limit, :offset => @items_offset}.merge(options)) 
     457    return finder.send(finder_method, :all, {:readonly => true, :limit => @items_limit, :offset => @items_offset, :order => sort_sql}.merge(options)) 
    455458  end 
    456459end 
  • branches/workorder_report_rename/app/controllers/asset_tree_controller.rb

    r469 r487  
    110110    end 
    111111 
    112     # If user was viewing a form, a work order or an attachment 
     112    # If user was viewing a form, a task or an attachment 
    113113    # redirect to the appropriate list page. 
    114114    return redirect_to(:controller => 'form', :action=> 'list') if request.env['HTTP_REFERER'] =~ /form\/.*$/x 
  • branches/workorder_report_rename/app/controllers/form_controller.rb

    r469 r487  
    290290  # Called by AJAX 
    291291  def auto_complete_for_form_keywords 
    292     input = @request.raw_post.split.last 
     292    input = request.raw_post.split.last 
    293293    input.gsub!("form%5Bkeywords%5D=", "") 
    294294    input.gsub!("%C3%A4", "À") 
  • branches/workorder_report_rename/app/controllers/overview_controller.rb

    r469 r487  
    22# See license agreement for additional rights 
    33 
    4 include Graph 
     4require_dependency 'graph' 
    55 
    66# Class: OverviewController 
     
    3333        image = generate_time_spent_on_tasks_chart 
    3434      else 
    35         image = pie(300, 200, [1, 1], ['Empty', 'Empty']) 
     35        image = Graph::pie(300, 200, [1, 1], ['Empty', 'Empty']) 
    3636    end 
    3737     
     
    4848    } 
    4949 
    50     return pie(300, 200, form_counts, form_types.collect { |type| type.name }) 
     50    return Graph::pie(300, 200, form_counts, form_types.collect { |type| type.name }) 
    5151  end 
    5252 
     
    5757    } 
    5858 
    59     return pie(300, 200, task_counts, [_('New'), _('Assigned'), _('Accepted')]) 
     59    return Graph::pie(300, 200, task_counts, [_('New'), _('Assigned'), _('Accepted')]) 
    6060  end 
    6161 
     
    6363    find_selected_assets 
    6464    times = Task.average_times_from_open_state(@selected_assets_condition) 
    65     return bar(300, 200, times, [_('Assigned'), _('Accepted'), _('Closed')]) 
     65    return Graph::bar(300, 200, times, [_('Assigned'), _('Accepted'), _('Closed')]) 
    6666  end 
    6767 
     
    6969    find_selected_assets 
    7070    resource_usage = Task.calculate_resource_usage(@selected_assets_condition, 2.days, 30.minutes) 
    71     return line(300, 200, [resource_usage], [_('Resource usage')]) 
     71    return Graph::line(300, 200, [resource_usage], [_('Resource usage')]) 
    7272  end 
    7373end 
  • branches/workorder_report_rename/app/controllers/search_controller.rb

    r469 r487  
    3030    } 
    3131 
    32     # Search work orders "{3432}" "{43242" 
     32    # Search tasks "{3432}" "{43242" 
    3333    search_string.scan(/\{([[:digit:]]+)/) { |id| 
    3434      id = id.first.to_i 
     
    3737        return 
    3838      else 
    39         flash[:notice] = _('Work order {%i} not found', id) 
     39        flash[:notice] = _('Task {%i} not found', id) 
    4040      end 
    4141    } 
  • branches/workorder_report_rename/app/controllers/task_controller.rb

    r468 r487  
    2626  # ============== 
    2727  # 
    28   # Lists work orders for asset @selected_asset. 
    29   # Optionally also lists work orders for all asset's subassets: 
     28  # Lists tasks for asset @selected_asset. 
     29  # Optionally also lists tasks for all asset's subassets: 
    3030  def list 
    3131    define_priority_options 
    3232    @fields = [  
    33                 [_('ID'), :self], 
    34                 [_('Type'), :task_type_name], 
    35                 [_('State'), {:name => :state}.merge(@state_to_text)], 
    36                 [_('Description'), :short_description], 
    37                 [_('Priority'), {:name => :priority}.merge(@priority_to_text)], 
    38                 [_('Responsible worker'), :responsible_user], 
    39                 [_('Starting time'), :starting_time], 
    40                 [_('Deadline'), :deadline], 
    41                 [_('Asset'), :asset
     33                [_('ID'), :self, 'id'], 
     34                [_('Type'), :task_type_name, 'task_type_id'], 
     35                [_('State'), {:name => :state}.merge(@state_to_text), 'state'], 
     36                [_('Description'), :short_description, 'short_description'], 
     37                [_('Priority'), {:name => :priority}.merge(@priority_to_text), 'priority'], 
     38                [_('Responsible worker'), :responsible_user, 'responsible_user_id'], 
     39                [_('Starting time'), :starting_time, 'starting_time'], 
     40                [_('Deadline'), :deadline, 'deadline'], 
     41                [_('Asset'), :asset, 'asset_id'
    4242              ] 
     43     
     44    user_options = @selected_asset.users.collect { |user| [user.login_and_name, user.id] } 
     45    asset_options = Asset.find_authorized_to(:create_task, [:all]).collect { |a| [a.full_code, a.id] } 
    4346    @actions = [] 
     47    @check_title = _('Select') 
     48    @list_actions =  [ 
     49                  { :name => _('Remove'), :url => {:action => 'remove'} }, 
     50                  { :name => _('Move'), :url => {:action => 'move'}, 
     51                    :fields => [ [_('Asset'), :our_select_tag, 'asset_id', asset_options] ] } 
     52                ] 
    4453 
    4554    if session[:select_branches] 
    46       @title = _('Work orders for selected assets in branch %s', @selected_asset.code_and_name) 
     55      @title = _('Tasks for selected assets in branch %s', @selected_asset.code_and_name) 
    4756    else 
    48       @title = _('Work orders for asset %s', @selected_asset.code_and_name) 
     57      @title = _('Tasks for asset %s', @selected_asset.code_and_name) 
    4958    end 
    5059 
     
    7584    @users = @task.asset.users(@task.responsible_user_id) 
    7685 
    77     @wo_title = _('Work order %s (%s)', @task.to_s, @task.task_type.name) 
     86    @wo_title = _('Task %s (%s)', @task.to_s, @task.task_type.name) 
    7887    define_priority_options 
    7988 
     
    8796      # Trigger the gettext 
    8897      # FIXME: Come up with something better 
    89       _('You have been removed from the list of workers in this work order') 
    90       _('You have been added to the list of workers in this work order') 
     98      _('You have been removed from the list of workers in this task') 
     99      _('You have been added to the list of workers in this task') 
    91100 
    92101      for worker_id in removed_worker_ids 
    93102        next if worker_id == session[:user].id 
    94103        Message.create(:receiver_user_id => worker_id, 
    95                     :subject => 'You have been removed from the list of workers in this work order', 
     104                    :subject => 'You have been removed from the list of workers in this task', 
    96105                    :body => "{#{@task.id}}") 
    97106      end 
     
    100109        next if worker_id == session[:user].id 
    101110        Message.create(:receiver_user_id => worker_id, 
    102                     :subject => 'You have been added to the list of workers in this work order', 
     111                    :subject => 'You have been added to the list of workers in this task', 
    103112                    :body => "{#{@task.id}}") 
    104113      end 
     
    111120      when 'accept' 
    112121        @task.accept 
    113         flash[:notice] = _('Work order accepted') 
     122        flash[:notice] = _('Task accepted') 
    114123      when 'close' 
    115124        @task.close 
    116         flash[:notice] = _('Work order closed') 
     125        flash[:notice] = _('Task closed') 
    117126      when 'assign' 
    118127        @task.assign_to(User.find(params[:responsible_user_id])) 
    119         flash[:notice] = _('Work order assigned') 
     128        flash[:notice] = _('Task assigned') 
    120129      when 'reopen': 
    121130        @task.open 
    122         flash[:notice] = _('Work order reopened') 
     131        flash[:notice] = _('Task reopened') 
    123132      else 
    124         flash[:error] = _('Unknown work order action!') 
     133        flash[:error] = _('Unknown task action!') 
    125134        return 
    126135      end 
     
    154163    @users = User.find :all # Data permissions will change 
    155164 
    156     @title = _('Editing work order #%i (%s)', @task.id, @task.task_type.name) 
     165    @title = _('Editing task #%i (%s)', @task.id, @task.task_type.name) 
    157166 
    158167    if request.post? 
     
    186195  def create 
    187196    unless @selected_asset.authorized_to_create_task? 
    188       redirect_with_error_message(msg_unauthorized_operation(_('create work order'), @selected_asset.code_and_name), :action => 'list') 
     197      redirect_with_error_message(msg_unauthorized_operation(_('create task'), @selected_asset.code_and_name), :action => 'list') 
    189198      return 
    190199    end 
     
    192201    define_priority_options 
    193202 
    194     @title = _('Create new work order') 
     203    @title = _('Create new task') 
    195204    @hide_subaction_links = true 
    196205    @cause_form_id = params[:cause_form_id] if params[:cause_form_id] 
     
    198207 
    199208    if @task_types.empty? 
    200       redirect_with_message(_('No work order types defined.'), :action=>'list') 
     209      redirect_with_message(_('No task types defined.'), :action=>'list') 
    201210      return 
    202211    end 
     
    217226      @task.ready = true 
    218227      if @task.save(true) 
    219         flash[:notice] = _('New work order created') 
    220         info('New work order created') 
     228        flash[:notice] = _('New task created') 
     229        info('New task created') 
    221230        redirect_to :action => 'view', :id => @task.id 
    222231      else 
     
    230239  def move 
    231240    begin 
    232       @task = Task.find(params[:id], :include => [:data_permissions, :asset, :creator, :responsible_user]) 
     241      if params[:id] 
     242        @task = Task.find(params[:id], :include => [:data_permissions, :asset, :creator, :responsible_user]) 
     243      elsif params[:delete] # Mass move 
     244        tasks = Task.find(params[:delete].keys, :include => [:data_permissions, :asset, :creator, :responsible_user]) 
     245      end 
    233246    rescue ActiveRecord::RecordNotFound 
    234247        redirect_with_error_message(msg_non_existing_data(Task, params[:id]), :action => 'list') 
    235248    end 
    236249     
    237     unless @task.authorized_to_edit? 
    238       redirect_with_error_message(msg_unauthorized_operation(_('edit'), "{#{@task.id}}"), :action => 'list') 
    239       return 
    240     end 
    241      
    242     @replace_actions = [] 
    243     @title = _('Move the work order {%i} to a another asset', @task.id) 
    244     asset_options = (Asset.find_authorized_to(:create_task, [:all]) - [@task.asset]).collect { |a| 
    245       [a.full_code, a.id] 
    246     } 
    247     @fields = [ [_('Asset'), 'task', 'asset_id', asset_options ] ] 
    248     @hidden_fields = [ ['id', @task.id] ] 
    249  
    250     if request.post? 
    251       new_asset = Asset.find_authorized_to(:create_task, [params[:task][:asset_id]]) 
    252       if @task.move(new_asset.id) 
    253         flash[:notice] = _('The work order {%i} moved to the asset %s', @task.id, new_asset.full_code) 
    254         redirect_to(:action => 'list') 
     250    if @task 
     251      unless @task.authorized_to_edit? 
     252        redirect_with_error_message(msg_unauthorized_operation(_('edit'), "{#{@task.id}}"), :action => 'list') 
    255253        return 
    256254      end 
    257  
    258       flash[:error] = _('Unable to move the work order {%i} to the asset %s', @task.id, new_asset.full_code) 
    259     end 
    260  
    261     render(:partial => 'shared/select', :layout => 'mainlevel', :locals => { :submit_text => _('Move'), :cancel_url_options => {:action => 'list'} }) 
     255       
     256      @replace_actions = [] 
     257      @title = _('Move the task {%i} to a another asset', @task.id) 
     258      asset_options = (Asset.find_authorized_to(:create_task, [:all]) - [@task.asset]).collect { |a| 
     259        [a.full_code, a.id] 
     260      } 
     261      @fields = [ [_('Asset'), 'task', 'asset_id', asset_options ] ] 
     262      @hidden_fields = [ ['id', @task.id] ] 
     263 
     264      if request.post? 
     265        new_asset = Asset.find_authorized_to(:create_task, [params[:task][:asset_id]]) 
     266        if @task.move(new_asset.id) 
     267          flash[:notice] = _('The task {%i} moved to the asset %s', @task.id, new_asset.full_code) 
     268          redirect_to(:action => 'list') 
     269          return 
     270        end 
     271 
     272        flash[:error] = _('Unable to move the task {%i} to the asset %s', @task.id, new_asset.full_code) 
     273      end 
     274 
     275      render(:partial => 'shared/select', :layout => 'mainlevel', :locals => { :submit_text => _('Move'), :cancel_url_options => {:action => 'list'} }) 
     276    else # Mass move 
     277      redirect_to(:action => 'list') 
     278      return if not request.post? or not tasks or tasks.empty? 
     279 
     280      new_asset = Asset.find_authorized_to(:create_task, [params[:asset_id]]) 
     281      move_count = 0 
     282      for task in tasks 
     283        unless task.authorized_to_edit? 
     284          add_to_error_message(msg_unauthorized_operation(_('edit'), "{#{@task.id}}")) 
     285          next  
     286        end 
     287 
     288        if task.move(new_asset.id) 
     289          move_count += 1 
     290        else 
     291          add_to_error_message(_('Unable to move task {%i}', task.id)) 
     292        end 
     293      end 
     294      flash[:notice] = _("Moved %d tasks to asset %s", move_count, new_asset.full_code).pluralize if move_count > 0 
     295    end 
     296  end 
     297 
     298  def update_states 
     299    raise params.inspect 
    262300  end 
    263301 
     
    280318    # Check that we have a template 
    281319    unless task_template 
    282       flash[:error] = _('Template for work orders not found') 
     320      flash[:error] = _('Template for tasks not found') 
    283321      redirect_to :back 
    284322      return 
     
    291329    end 
    292330 
    293     # Generate document for the work order 
     331    # Generate document for the task 
    294332    document = task_template.create_filled_version(task) 
    295333 
     
    314352    dir_name = "task_#{task.id}/" 
    315353 
    316     # Write work order 
     354    # Write task 
    317355    zout.put_next_entry(dir_name + "task_#{task.id}.odt") 
    318356    zout.write(document.data) 
  • branches/workorder_report_rename/app/controllers/task_type_controller.rb

    r468 r487  
    1111class TaskTypeController < ApplicationController 
    1212  prepend_before_filter :login_required 
    13   layout 'mainlevel' 
    1413 
    1514  # Fields for create and edit actions 
     
    1716  # Displays the task type listing 
    1817  def list 
    19     @title = _('Work order types') 
     18    @title = _('Task types') 
    2019    @fields = [ [_('Name'), :name], 
    2120                [_('Tag'), :task_tag], 
    2221                [_('Description'), :description], 
    23                 [_('Work order count'), :task_count] 
     22                [_('Task count'), :task_count] 
    2423              ] 
    2524    @items = items_for_page(TaskType, :order => 'task_tag_id, name') 
     
    2827 
    2928  def create 
    30     @title = _('New work order type') 
     29    @title = _('New task type') 
    3130    @fields = [ 
    3231                [_('Name'), :text_field, 'name', { :size => 40, :maxlength => 40 } ], 
     
    4746 
    4847  def edit 
    49     @title = _('Edit work order type') 
     48    @title = _('Edit task type') 
    5049    @fields = [ 
    5150                [_('Name'), :text_field, 'name', { :size => 40, :maxlength => 40 } ], 
     
    7877 
    7978    unless template 
    80       flash[:error] = _('No work order template uploaded!') 
     79      flash[:error] = _('No task template uploaded!') 
    8180      redirect_to :back 
    8281      return 
  • branches/workorder_report_rename/app/controllers/user_controller.rb

    r469 r487  
    156156 
    157157  def login 
    158     if @request.post? 
     158    if request.post? 
    159159      if session[:user] = User.authenticate(params[:user_login], params[:user_password]) 
    160         session[:user_ip] = @request.remote_ip 
     160        session[:user_ip] = request.remote_ip 
    161161        session[:user_timeout] = 2.hours.from_now 
    162162        session[:show_asset_tree] = true 
  • branches/workorder_report_rename/app/helpers/application_helper.rb

    r469 r487  
    434434  # ============================ 
    435435  # 
    436   # Returns a link to work order 
    437   # 
    438   # Parameters: 
    439   # ----------- 
    440   # task - Work order to link to 
    441   # link_only  - If true, the 'Work order' text is not displayed. 
    442   # show_type - If true, the work order's type will be displayed 
     436  # Returns a link to task 
     437  # 
     438  # Parameters: 
     439  # ----------- 
     440  # task - Task to link to 
     441  # link_only  - If true, the 'Task' text is not displayed. 
     442  # show_type - If true, the task's type will be displayed 
    443443  def link_to_task(task, link_only = false, show_type = true) 
    444444    return '' unless task 
     
    451451    #link = "<a href=\"/task/view/#{task.id}\" class=\"task\">#{link_title}</a>" 
    452452    return link if link_only 
    453     return _('Work order') + ' ' + link 
     453    return _('Task') + ' ' + link 
    454454  end 
    455455 
     
    630630          else 
    631631            b.push({:method => 'get'}) if b.size == 2 
    632             "<td>#{form_tag(b[1], b[2]) + submit_tag(b[0]) + end_form_tag}</td>" 
     632            "<td>#{form_tag(b[1], b[2]) + submit_tag(b[0])}</form></td>" 
    633633          end 
    634634        else 
     
    653653    return table unless include_submit_tag_and_end_form 
    654654 
    655     table + end_form_tag 
     655    table + '</form>' 
    656656  end 
    657657 
     
    788788    return results.join 
    789789  end 
     790 
     791  # Select tag that support option collections. The collection is converted 
     792  # to option tags with options_for_select. 
     793  def our_select_tag(name, option_collection = nil, options = {}) 
     794    option_tags = options_for_select(option_collection) if option_collection 
     795    return select_tag(name, option_tags, options) 
     796  end 
    790797end 
  • branches/workorder_report_rename/app/helpers/asset_helper.rb

    r469 r487  
    7979    result_items += condition_list_item(:red, sprintf(n_('%d unprocessed %s form:', '%d unprocessed %s forms:', results[:unprocessed_requests].last.size), results[:unprocessed_requests].last.size, results[:unprocessed_requests].first), results[:unprocessed_requests].last) if results.has_key?(:unprocessed_requests) 
    8080 
    81     result_items += condition_list_item(:orange, sprintf(n_('%d new %s work order:', '%d new %s work orders:', results[:new_works].last.size), results[:new_works].last.size, results[:new_works].first), results[:new_works].last) if results.has_key?(:new_works) 
     81    result_items += condition_list_item(:orange, sprintf(n_('%d new %s task:', '%d new %s tasks:', results[:new_works].last.size), results[:new_works].last.size, results[:new_works].first), results[:new_works].last) if results.has_key?(:new_works) 
    8282 
    83     result_items += condition_list_item(:green, sprintf(n_('%d assigned or accepted %s work order:', '%d assigned or accepted %s work orders:', results[:assigned_works].last.size), results[:assigned_works].last.size, results[:assigned_works].first), results[:assigned_works].last) if results.has_key?(:assigned_works) 
     83    result_items += condition_list_item(:green, sprintf(n_('%d assigned or accepted %s task:', '%d assigned or accepted %s tasks:', results[:assigned_works].last.size), results[:assigned_works].last.size, results[:assigned_works].first), results[:assigned_works].last) if results.has_key?(:assigned_works) 
    8484 
    85     result_items += condition_list_item(:orange, sprintf(n_('%d unfinished %s work order. No %s form has been filed:', '%d unfinished %s work orders. No %s form has been filed:', results[:unknown_condition].last.size), results[:unknown_condition].last.size, *results[:unknown_condition].first), results[:unknown_condition].last) if results.has_key?(:unknown_condition) 
     85    result_items += condition_list_item(:orange, sprintf(n_('%d unfinished %s task. No %s form has been filed:', '%d unfinished %s tasks. No %s form has been filed:', results[:unknown_condition].last.size), results[:unknown_condition].last.size, *results[:unknown_condition].first), results[:unknown_condition].last) if results.has_key?(:unknown_condition) 
    8686 
    8787    result_items += condition_list_item(:green, sprintf(n_('%d recent %s form:', '%d recent %s forms:', results[:recent_condition].last.size), results[:recent_condition].last.size, results[:recent_condition].first), results[:recent_condition].last) if results.has_key?(:recent_condition) 
     
    9393    results = asset.analyse_maintenance_chain 
    9494    result_items = '' 
    95     result_items += condition_list_item(:red, sprintf(n_('%d new %s work order:', '%d new %s work orders:', results[:new_works].last.size), results[:new_works].last.size, results[:new_works].first), results[:new_works].last) if results.has_key?(:new_works) 
    96     result_items += condition_list_item(:green, sprintf(n_('%d assigned or accepted %s work order:', '%d assigned or accepted %s work orders:', results[:assigned_works].last.size), results[:assigned_works].last.size, results[:assigned_works].first), results[:assigned_works].last) if results.has_key?(:assigned_works) 
     95    result_items += condition_list_item(:red, sprintf(n_('%d new %s task:', '%d new %s tasks:', results[:new_works].last.size), results[:new_works].last.size, results[:new_works].first), results[:new_works].last) if results.has_key?(:new_works) 
     96    result_items += condition_list_item(:green, sprintf(n_('%d assigned or accepted %s task:', '%d assigned or accepted %s tasks:', results[:assigned_works].last.size), results[:assigned_works].last.size, results[:assigned_works].first), results[:assigned_works].last) if results.has_key?(:assigned_works) 
    9797 
    98     result_items += condition_list_item(:orange, sprintf(n_('%d unfinished %s work order. No %s form has been filed:', '%d unfinished %s work orders. No %s form has been filed:', results[:unknown_condition].last.size), results[:unknown_condition].last.size, *results[:unknown_condition].first), results[:unknown_condition].last) if results.has_key?(:unknown_condition) 
     98    result_items += condition_list_item(:orange, sprintf(n_('%d unfinished %s task. No %s form has been filed:', '%d unfinished %s tasks. No %s form has been filed:', results[:unknown_condition].last.size), results[:unknown_condition].last.size, *results[:unknown_condition].first), results[:unknown_condition].last) if results.has_key?(:unknown_condition) 
    9999 
    100100    result_items += condition_list_item(:green, sprintf(n_('%d recent %s form:', '%d recent %s forms:', results[:recent_maintenance].last.size), results[:recent_maintenance].last.size, results[:recent_maintenance].first), results[:recent_maintenance].last) if results.has_key?(:recent_maintenance) 
  • branches/workorder_report_rename/app/models/asset_condition_analysis.rb

    r469 r487  
    1515 
    1616    unless task_type_ids.empty? 
    17       # Find "Service request" forms which haven't led to work orders. 
     17      # Find "Service request" forms which haven't led to tasks. 
    1818      unless cause_form_type_ids.empty? 
    19         # First find ids of forms which have led to work orders. 
     19        # First find ids of forms which have led to tasks. 
    2020        cause_form_ids = Task.find(:all, :select => 'cause_form_id,' + Task.minimal_select, :conditions => ['asset_id = ? AND task_type_id IN (?) AND cause_form_id IS NOT NULL', self.id, task_type_ids]).map {|w| w.cause_form_id } 
    2121        conditions = ['asset_id = ? AND form_type_id IN (?)', self.id, cause_form_type_ids] 
     
    2828      end 
    2929 
    30       # Find new "Service" work orders. 
     30      # Find new "Service" tasks. 
    3131      found = Task.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND task_type_id IN (?) AND state = ?', self.id, task_type_ids, Task.NEW], :readonly => true) 
    3232      result[:new_works] = [task_tag.name, found] unless found.empty? 
    3333 
    34       # Find "Service" work orders which have been assigned or accepted. 
     34      # Find "Service" tasks which have been assigned or accepted. 
    3535      found = Task.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND task_type_id IN (?) AND state IN (?)', self.id, task_type_ids, [Task.ASSIGNED, Task.ACCEPTED]], :readonly => true) 
    3636      result[:assigned_works] = [task_tag.name, found] unless found.empty? 
    3737 
    38       # Find closed "Service" work orders, which haven't led to "Condition" forms. 
     38      # Find closed "Service" tasks, which haven't led to "Condition" forms. 
    3939      unless effect_form_type_ids.empty? 
    40         # First find ids of work orders which have led to forms. 
     40        # First find ids of tasks which have led to forms. 
    4141        cause_task_ids = Form.find(:all, :select => 'cause_task_id,' + Form.minimal_select, :conditions => ['asset_id = ? AND form_type_id IN (?) AND cause_task_id IS NOT NULL', self.id, effect_form_type_ids]).map {|w| w.cause_task_id } 
    4242        conditions = ['asset_id = ? AND task_type_id IN (?) AND tasks.state = ?', self.id, task_type_ids, Task.CLOSED] 
     
    6868 
    6969    unless cause_task_type_ids.empty? 
    70       # Find new "Maintenance" work order
     70      # Find new "Maintenance" task
    7171      found = Task.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND task_type_id IN (?) AND state = ?', self.id, cause_task_type_ids, Task.NEW]) 
    7272      result[:new_works] = [cause_task_tag.name, found] unless found.empty? 
    7373 
    74       # Find "Maintenance" work orders which have been assigned or accepted. 
     74      # Find "Maintenance" tasks which have been assigned or accepted. 
    7575      found = Task.find_authorized_to_read(:all, :conditions => ['asset_id = ? AND task_type_id IN (?) AND state IN (?)', self.id, cause_task_type_ids, [Task.ASSIGNED, Task.ACCEPTED]]) 
    7676      result[:assigned_works] = [cause_task_tag.name, found] unless found.empty? 
    7777 
    78       # Find closed "Maintenance" work orders, which haven't led to "Maintenance" forms. 
     78      # Find closed "Maintenance" tasks, which haven't led to "Maintenance" forms. 
    7979      unless effect_form_type_ids.empty? 
    80         # First find ids of work orders which have led to forms. 
     80        # First find ids of tasks which have led to forms. 
    8181        cause_task_ids = Form.find(:all, :select => 'cause_task_id,' + Form.minimal_select, :conditions => ['asset_id = ? AND form_type_id IN (?) AND cause_task_id IS NOT NULL', self.id, effect_form_type_ids]).map {|w| w.cause_task_id } 
    8282        conditions = ['asset_id = ? AND task_type_id IN (?) AND tasks.state = ?', self.id, cause_task_type_ids, Task.CLOSED] 
  • branches/workorder_report_rename/app/models/assets_user_group.rb

    r469 r487  
    5656            self.form_permission_profiles.clear 
    5757          end 
    58           # For Work order
     58          # For Task
    5959          if original_create_task == false and self.create_task == true 
    6060            self.task_permission_profiles.create(:user_group_id => self.user_group_id, :group_read => true) 
  • branches/workorder_report_rename/app/models/form.rb

    r469 r487  
    1010  # Associations 
    1111  belongs_to :form_type 
    12   belongs_to :cause_task, :class_name => 'Task', :foreign_key => 'cause_task_id' # work order which caused this form 
    13   has_one :effect_task, :class_name => 'Task', :foreign_key => 'cause_form_id' # work order which was caused by this form 
     12  belongs_to :cause_task, :class_name => 'Task', :foreign_key => 'cause_task_id' # task which caused this form 
     13  has_one :effect_task, :class_name => 'Task', :foreign_key => 'cause_form_id' # task which was caused by this form 
    1414  has_many :form_field_values, :dependent => :delete_all 
    1515  has