Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.34 KB | None | 0 0
  1. class Edms::OvertimeDefinitionsController < ApplicationController
  2.  
  3. require 'will_paginate/array'
  4. layout :compute_layout
  5.  
  6.  
  7. def new
  8. @flag = params[:flag]
  9. @employee = Employee.find(params[:id])
  10. @overtime = OvertimeDefinition.new
  11. end
  12.  
  13. def create
  14. @employee = Employee.find(params[:overtime_definition][:employee_id])
  15. @overtime = OvertimeDefinition.new(params[:overtime_definition])
  16. if (params[:half_day_extra_duty_hours][:hour].to_s !="" || params[:half_day_extra_duty_hours][:minute].to_s !="")
  17. @overtime.half_day_extra_duty_hours = params[:half_day_extra_duty_hours][:hour].to_s + ":" + params[:half_day_extra_duty_hours][:minute].to_s + ":" + "00"
  18. else
  19. @overtime.half_day_extra_duty_hours = nil
  20. end
  21. if (params[:full_day_extra_duty_hours][:hour].to_s !="" || params[:full_day_extra_duty_hours][:minute].to_s !="")
  22. @overtime.full_day_extra_duty_hours = params[:full_day_extra_duty_hours][:hour].to_s + ":" + params[:full_day_extra_duty_hours][:minute].to_s + ":" + "00"
  23. else
  24. @overtime.full_day_extra_duty_hours = nil
  25. end
  26. if @overtime.save
  27. flash[:notice] = "Overtime Successfully Created for #{@employee.name}"
  28. redirect_to :action => 'search_overtime'
  29. end
  30. end
  31.  
  32. def edit
  33. @flag = params[:flag]
  34. @overtime = OvertimeDefinition.find(params[:id])
  35. @employee = Employee.find(params[:employee_id])
  36. end
  37.  
  38. def update
  39. @employee = Employee.find(params[:id])
  40. @overtime = OvertimeDefinition.find(params[:id])
  41. if @overtime.update_attributes(params[:overtime_definition])
  42. flash[:notice] = "Overtime Successfully Updated for #{@employee.name}"
  43. redirect_to :action => 'search_overtime'
  44. else
  45. render :action => 'edit',:flag=>params[:flag]
  46. end
  47. end
  48.  
  49. def search_overtime
  50. @overtimes = OvertimeDefinition.all
  51. @departments = @site.is_central ? {} : @site.departments
  52. @designations = @site.is_central ? {} : @site.designations
  53. @active_profile = @site.is_central ? Employee.get_all_employees.paginate(:page => params[:page]) : @site.employees.get_all_employees.paginate(:page => params[:page])
  54. if request.xml_http_request?
  55. render :update do |page|
  56. page['search_result_div'].replace_html :partial => "search_overtime_employee_list"
  57. end
  58. end
  59. end
  60.  
  61. <%= form_tag :action => 'update',:id => @overtime.id,:employee_id => @employee.id,:flag=> params[:flag] %>
  62. <%= render :partial =>'form' %>
  63. <center>
  64. <%= submit_tag "Update",:onclick=>"return validate()",:class=>"buttons" %>
  65. </center>
  66. <%= link_to "Back" ,:action => "search_overtime" %>
  67.  
  68. <table cellspacing="5">
  69. <tr>
  70. <td><b>Employee Code</b></td>
  71. <%= hidden_field 'overtime_definition','employee_id',:value=>params[:id] %>
  72. <td><%= @employee.employeeid %></td>
  73. <td><b>Employee Name</b></td>
  74. <td><%= @employee.personnel.display_full_name %></td>
  75. </tr>
  76. <tr>
  77. <td><b>Department</b></td>
  78. <td><%= @employee.department ? @employee.department.name : "" %></td>
  79. <td><b>Designation</b></td>
  80. <td><%= @employee.designation ? @employee.designation.name : "" %></td>
  81. <td><b>Location</b></td>
  82. <td><%= @employee.location.name%></td>
  83. </tr>
  84. </table>
  85.  
  86. </br>
  87. <fieldset>
  88. <table cellspacing="5">
  89. <%= form_for :overtime_definition, :builder => LabelFormBuilder do |od| %>
  90. <tr>
  91. <td>
  92. <label for="half_day_extra_duty_hours">
  93. Half Day Extra Duty Hours
  94. </label>
  95. </td>
  96. <td class ="datefamily">
  97. <%= select_time(@overtime.half_day_extra_duty_hours, {:include_blank => true, :time_separator => ":",:prefix => "half_day_extra_duty_hours"})%>
  98. </td>
  99. </tr>
  100. <tr>
  101. <td>
  102. <label for="full_day_extra_duty_hours">
  103. Full Day Extra Duty Hours
  104. </label>
  105. </td>
  106. <td class ="datefamily">
  107. <%= select_time(@overtime.full_day_extra_duty_hours, {:include_blank => true, :time_separator => ":",:prefix => "full_day_extra_duty_hours"})%>
  108. </td>
  109. </tr>
  110. <tr>
  111. <%= od.sr_check_box :is_salary_basis, {}, true, false, :label => "Is Salary Basis"%>
  112. </tr>
  113. <tr>
  114. <%= od.sr_check_box :is_fixed_amount, {}, true, false, :label => "Is Fixed Amount"%>
  115. <td colspan="2" id="ov_hm" style="display: none">
  116. Half Day Amount
  117. <%= od.text_field :half_day_amount, :onkeypress => "return numbersonly(event)", :style => "width:40px" %>
  118. </td>
  119. <td colspan="2" id="ov_fm" style="display: none">
  120. Full Day Amount
  121. <%= od.text_field :full_day_amount, :onkeypress => "return numbersonly(event)", :style => "width:40px" %>
  122. </td>
  123. </tr>
  124. <% end %>
  125. </table>
  126. </fieldset>
  127.  
  128. <table cellspacing="0" cellpadding="0" width="100%" id='type'>
  129. <tr class="tblebluehead">
  130. <th>
  131. SI.NO
  132. </th>
  133. <th>
  134. Code
  135. </th>
  136. <th>
  137. Name
  138. </th>
  139. <th>
  140. Department
  141. </th>
  142. <th>
  143. Designation
  144. </th>
  145. <th colspan="3">
  146. Functions
  147. </th>
  148. </tr>
  149. <% count=0 %><% i=0 %>
  150. <% for employee in @active_profile %>
  151. <% if i%2==0 %>
  152. <tr class="tablerow1">
  153. <% else %>
  154. <tr class="tablerow2">
  155. <%end %><% i=i+1 %>
  156. <td>
  157. <%= count=count+1 %>
  158. </td>
  159. <td>
  160. <%= employee.employeeid %>
  161. </td>
  162. <td>
  163. <%=h employee.name %>
  164. <%resigned = EmployeeSeparationDetail.find(:first, :conditions => ["employee_id =? and status ='Active' and approval_status ='Approved'", employee.id])%>
  165. <% if resigned %>
  166. <span style="color:red"> (R)</span>
  167. <% end %>
  168. </td>
  169. <td>
  170. <%=h employee.department ? employee.department.name : ""%>
  171. </td>
  172. <td>
  173. <%=h employee.designation ? employee.designation.name : "" %>
  174. </td>
  175. <td>
  176. <%=link_to "Calculation" ,:action => "new",:id=>employee.id,:flag=>"Calculation" %>
  177. </td>
  178. <% for overtime in @overtimes %>
  179. <% if overtime.employee_id == employee.id%>
  180. <td>
  181. <%= link_to "Re-Calculate",:action => "edit",:id=>overtime.id,:employee_id => employee.id,:flag=>"Re-Calculate" %>
  182. </td>
  183. <% end %>
  184. <% end %>
  185. </tr>
  186. <% end %>
  187. </table>
  188. <b> <%= will_paginate @active_profile,:next_label => ">>" ,:prev_label => "<<"%></b>
  189.  
  190. Started POST "/edms/overtime_definitions/update/249?employee_id=1353&flag=Re-Calculate" for 127.0.0.1 at 2014-04-09 15:12:45 +0530
  191. Processing by Edms::OvertimeDefinitionsController#update as HTML
  192. Parameters: {"utf8"=>"✓", "authenticity_token"=>"NT+iv9FBJy87aabbNLALf50LkKv07yOR7xFA9Oe3ijs=", "overtime_definition"=>{"employee_id"=>"1353", "is_salary_basis"=>"1", "is_fixed_amount"=>"0", "half_day_amount"=>"", "full_day_amount"=>""}, "half_day_extra_duty_hours"=>{"year"=>"2000", "month"=>"1", "day"=>"1", "hour"=>"02", "minute"=>"02"}, "full_day_extra_duty_hours"=>{"year"=>"2000", "month"=>"1", "day"=>"1", "hour"=>"04", "minute"=>"04"}, "commit"=>"Update", "employee_id"=>"1353", "flag"=>"Re-Calculate", "id"=>"249"}
  193.  
  194. <%= hidden_field 'overtime_definition','employee_id',:value=>@employee.id %>
  195.  
  196. @employee = Employee.find(params[:employee_id])
  197.  
  198. <%= form_tag :action => 'update',:id => @overtime.id,:employee_id => params[:employee_id],:flag=> params[:flag] %>
  199.  
  200. def update
  201. @employee = Employee.find(params[:id])
  202. @overtime = OvertimeDefinition.find(params[:id])
  203.  
  204. def update
  205. @employee = Employee.find(params[:id])
  206. @overtime = OvertimeDefinition.find(params[:employee_id])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement