pshq_engine 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +4 -0
  5. data/README.md +39 -0
  6. data/Rakefile +1 -0
  7. data/app/models/.keep +0 -0
  8. data/app/models/ability.rb +76 -0
  9. data/app/models/alert.rb +56 -0
  10. data/app/models/asset.rb +485 -0
  11. data/app/models/asset_assignment.rb +13 -0
  12. data/app/models/asset_image.rb +9 -0
  13. data/app/models/asset_repair_request.rb +167 -0
  14. data/app/models/asset_scan.rb +87 -0
  15. data/app/models/asset_ticket.rb +3 -0
  16. data/app/models/cancellation.rb +64 -0
  17. data/app/models/candidate.rb +127 -0
  18. data/app/models/certification.rb +4 -0
  19. data/app/models/concerns/.keep +0 -0
  20. data/app/models/depreciation_setting.rb +10 -0
  21. data/app/models/dispatch.rb +3 -0
  22. data/app/models/employee.rb +22 -0
  23. data/app/models/feedback.rb +24 -0
  24. data/app/models/history_email.rb +221 -0
  25. data/app/models/importfile.rb +6 -0
  26. data/app/models/job.rb +37 -0
  27. data/app/models/jobs_users.rb +18 -0
  28. data/app/models/lateness.rb +35 -0
  29. data/app/models/location.rb +4 -0
  30. data/app/models/manufacturer.rb +4 -0
  31. data/app/models/member.rb +65 -0
  32. data/app/models/member_device.rb +4 -0
  33. data/app/models/message.rb +33 -0
  34. data/app/models/note.rb +20 -0
  35. data/app/models/notification.rb +73 -0
  36. data/app/models/notification_user.rb +4 -0
  37. data/app/models/o_auth/base.rb +27 -0
  38. data/app/models/o_auth/facebook.rb +21 -0
  39. data/app/models/o_auth/google.rb +18 -0
  40. data/app/models/organization.rb +189 -0
  41. data/app/models/plan.rb +4 -0
  42. data/app/models/project.rb +5 -0
  43. data/app/models/project_payment.rb +4 -0
  44. data/app/models/recurring_time_off.rb +4 -0
  45. data/app/models/response.rb +23 -0
  46. data/app/models/role.rb +22 -0
  47. data/app/models/schedule.rb +228 -0
  48. data/app/models/setting.rb +25 -0
  49. data/app/models/shift.rb +364 -0
  50. data/app/models/shift_off.rb +4 -0
  51. data/app/models/shift_trade.rb +43 -0
  52. data/app/models/subdomain.rb +5 -0
  53. data/app/models/swap.rb +82 -0
  54. data/app/models/task.rb +26 -0
  55. data/app/models/template.rb +59 -0
  56. data/app/models/template_asset.rb +3 -0
  57. data/app/models/timeoff.rb +101 -0
  58. data/app/models/token.rb +22 -0
  59. data/app/models/transaction.rb +2 -0
  60. data/app/models/unavailable.rb +37 -0
  61. data/app/models/user.rb +392 -0
  62. data/app/models/user_notification_setting.rb +178 -0
  63. data/app/models/user_vacation_info.rb +22 -0
  64. data/app/models/vacation.rb +24 -0
  65. data/app/models/vendor.rb +130 -0
  66. data/app/models/vendor_rating.rb +7 -0
  67. data/bin/console +14 -0
  68. data/bin/setup +7 -0
  69. data/db/migrate/20140211085026_devise_create_users.rb +58 -0
  70. data/db/migrate/20140211093822_rolify_create_roles.rb +19 -0
  71. data/db/migrate/20140211124352_create_subdomains.rb +9 -0
  72. data/db/migrate/20140211175737_devise_invitable_add_to_users.rb +24 -0
  73. data/db/migrate/20140222020040_create_schedules.rb +13 -0
  74. data/db/migrate/20140222020246_create_jobs.rb +11 -0
  75. data/db/migrate/20140222020348_create_shifts.rb +17 -0
  76. data/db/migrate/20140222020425_create_organizations.rb +19 -0
  77. data/db/migrate/20140226070901_create_plans.rb +11 -0
  78. data/db/migrate/20140302152936_create_feedbacks.rb +12 -0
  79. data/db/migrate/20140302153059_create_swaps.rb +16 -0
  80. data/db/migrate/20140302153215_create_timeoffs.rb +19 -0
  81. data/db/migrate/20140302153302_create_cancellations.rb +13 -0
  82. data/db/migrate/20140306014858_create_candidates.rb +15 -0
  83. data/db/migrate/20140314041018_create_shift_trades.rb +15 -0
  84. data/db/migrate/20140314041210_create_notes.rb +11 -0
  85. data/db/migrate/20140314041313_create_latenesses.rb +11 -0
  86. data/db/migrate/20140314041351_create_vacations.rb +11 -0
  87. data/db/migrate/20140314041440_create_user_vacation_infos.rb +11 -0
  88. data/db/migrate/20140318072438_create_jobs_users.rb +10 -0
  89. data/db/migrate/20140325151307_create_tasks.rb +16 -0
  90. data/db/migrate/20140406040247_create_mailboxer.mailboxer_engine.rb +66 -0
  91. data/db/migrate/20140406040248_add_conversation_optout.mailboxer_engine.rb +15 -0
  92. data/db/migrate/20141015085628_create_alerts.rb +14 -0
  93. data/db/migrate/20141023104634_add_disabled_to_users.rb +5 -0
  94. data/db/migrate/20141024094518_add_is_viewed_to_schedules.rb +5 -0
  95. data/db/migrate/20141027091531_add_customer_id_to_users.rb +5 -0
  96. data/db/migrate/20141029124637_create_unavailables.rb +11 -0
  97. data/db/migrate/20141029151702_create_certifications.rb +10 -0
  98. data/db/migrate/20141105091745_add_reminder_time_to_shifts.rb +5 -0
  99. data/db/migrate/20141106054916_create_certifications_users.rb +10 -0
  100. data/db/migrate/20141106100123_add_birth_date_to_users.rb +5 -0
  101. data/db/migrate/20141106134815_add_allow_rolling_v_hrs_to_organizations.rb +5 -0
  102. data/db/migrate/20141107155319_create_recurring_time_offs.rb +12 -0
  103. data/db/migrate/20141111084845_add_termination_date_to_users.rb +5 -0
  104. data/db/migrate/20141111103759_add_requested_weekly_hours_to_users.rb +5 -0
  105. data/db/migrate/20141113094547_add_api_token_to_users.rb +5 -0
  106. data/db/migrate/20150105143729_create_templates.rb +9 -0
  107. data/db/migrate/20150105164236_add_coloumn_is_template.rb +5 -0
  108. data/db/migrate/20150106121306_add_org_id.rb +5 -0
  109. data/db/migrate/20150126070904_add_job_id_to_shifts.rb +6 -0
  110. data/db/migrate/20150203112955_add_time_zone_to_org.rb +5 -0
  111. data/db/migrate/20150204160711_add_show_owner_to_org.rb +5 -0
  112. data/db/migrate/20150210165627_add_training_hours_to_shift.rb +9 -0
  113. data/db/migrate/20150217131509_add_total_hours_to_schedules.rb +5 -0
  114. data/db/migrate/20150218094709_add_show_disable_users.rb +5 -0
  115. data/db/migrate/20150225134050_add_notes_to_cancellation.rb +9 -0
  116. data/db/migrate/20150226125524_add_unexcused_absence_note_to_cancellation.rb +9 -0
  117. data/db/migrate/20150226125811_add_cancel_shift_to_shifts.rb +9 -0
  118. data/db/migrate/20150302100542_add_picture_to_user.rb +9 -0
  119. data/db/migrate/20150304082219_add_priorty_to_user.rb +9 -0
  120. data/db/migrate/20150304094605_add_time_format_to_organization.rb +8 -0
  121. data/db/migrate/20150304142621_create_shift_offs.rb +15 -0
  122. data/db/migrate/20150306120726_add_shiftoff_to_shifts.rb +9 -0
  123. data/db/migrate/20150310103643_add_email_and_number_to_user.rb +11 -0
  124. data/db/migrate/20150311110055_add_one_sided_to_candidate.rb +9 -0
  125. data/db/migrate/20150318083934_add_notes_to_shift_trade.rb +9 -0
  126. data/db/migrate/20150408180855_add_column_status_to_unavailability.rb +8 -0
  127. data/db/migrate/20150409140324_create_assets.rb +35 -0
  128. data/db/migrate/20150409142753_create_vendors.rb +14 -0
  129. data/db/migrate/20150409144023_create_employees.rb +13 -0
  130. data/db/migrate/20150409144751_create_assign_assets.rb +16 -0
  131. data/db/migrate/20150409150449_create_asset_repair_requests.rb +19 -0
  132. data/db/migrate/20150409151023_create_dispatches.rb +13 -0
  133. data/db/migrate/20150409151329_create_vendor_ratings.rb +11 -0
  134. data/db/migrate/20150409151546_create_template_assets.rb +11 -0
  135. data/db/migrate/20150413101913_create_index_organization.rb +7 -0
  136. data/db/migrate/20150414153330_change_vendors.rb +16 -0
  137. data/db/migrate/20150420112003_add_name_to_users.rb +5 -0
  138. data/db/migrate/20150421074542_add_comment_to_ratings.rb +5 -0
  139. data/db/migrate/20150421131331_add_retire_column_to_assets.rb +5 -0
  140. data/db/migrate/20150422135600_add_attachment_avatar_to_assets.rb +11 -0
  141. data/db/migrate/20150422143242_create_importfiles.rb +8 -0
  142. data/db/migrate/20150422143301_add_attachment_avatar_to_importfiles.rb +11 -0
  143. data/db/migrate/20150423080234_change_retire_column.rb +5 -0
  144. data/db/migrate/20150423170953_add_attachment_avatar_to_vendors.rb +11 -0
  145. data/db/migrate/20150423225459_add_lockable.rb +7 -0
  146. data/db/migrate/20150427171842_create_asset_scans.rb +15 -0
  147. data/db/migrate/20150429211309_add_attachment_logo_to_organizations.rb +11 -0
  148. data/db/migrate/20150430074555_change_assets_table.rb +8 -0
  149. data/db/migrate/20150430235920_add_unique_email_index_to_users.rb +5 -0
  150. data/db/migrate/20150505104834_add_columntouser.rb +8 -0
  151. data/db/migrate/20150505140926_add_maintenance_cost_to_assets.rb +6 -0
  152. data/db/migrate/20150505142413_create_asset_images.rb +8 -0
  153. data/db/migrate/20150505152604_create_pg_search_documents.rb +17 -0
  154. data/db/migrate/20150506090012_change_employee.rb +12 -0
  155. data/db/migrate/20150506110441_add_status_to_asset_repair_requests.rb +6 -0
  156. data/db/migrate/20150507080738_change_phone_in_employees.rb +6 -0
  157. data/db/migrate/20150507101306_create_manufacturers.rb +12 -0
  158. data/db/migrate/20150507101446_remove.rb +9 -0
  159. data/db/migrate/20150507102211_add_index_manufacturer.rb +5 -0
  160. data/db/migrate/20150507104605_add_website_manufacturer.rb +5 -0
  161. data/db/migrate/20150507115535_change_refrence_manucaturer.rb +6 -0
  162. data/db/migrate/20150507150848_create_notifications.rb +9 -0
  163. data/db/migrate/20150507150855_create_notification_users.rb +10 -0
  164. data/db/migrate/20150508094912_add_landline_to_organization.rb +5 -0
  165. data/db/migrate/20150508143536_add_source_to_notifications.rb +7 -0
  166. data/db/migrate/20150508145048_add_postal_to_profile.rb +5 -0
  167. data/db/migrate/20150508162219_add_summary_to_notifications.rb +5 -0
  168. data/db/migrate/20150509220624_remove_responded_from_notifications.rb +5 -0
  169. data/db/migrate/20150509220625_add_responded_to_notifications.rb +5 -0
  170. data/db/migrate/20150509225608_change_columns_asset_repair_requests.rb +11 -0
  171. data/db/migrate/20150511105420_remove_avatar_asset.rb +6 -0
  172. data/db/migrate/20150514105700_add_unique_asset_id_to_asset.rb +5 -0
  173. data/db/migrate/20150515110042_add_deleted_at_in_assets.rb +6 -0
  174. data/db/migrate/20150515111410_add_deleted_at_vendors.rb +6 -0
  175. data/db/migrate/20150515113054_add_deleted_at_in_employee.rb +6 -0
  176. data/db/migrate/20150515142228_create_locations.rb +16 -0
  177. data/db/migrate/20150515142242_add_locations_to_assets.rb +5 -0
  178. data/db/migrate/20150515142536_add_organization_to_locations.rb +5 -0
  179. data/db/migrate/20150518123010_change_assign_asset.rb +9 -0
  180. data/db/migrate/20150518140153_add_asset_id_in_asset_assign.rb +5 -0
  181. data/db/migrate/20150518144758_rename_assign_assets.rb +8 -0
  182. data/db/migrate/20150518145248_rename_asset_assignment.rb +8 -0
  183. data/db/migrate/20150519140425_change_empid_to_string.rb +6 -0
  184. data/db/migrate/20150521085132_change_uique_asset_id_to_string.rb +6 -0
  185. data/db/migrate/20150525095045_add_status_to_organizations.rb +5 -0
  186. data/db/migrate/20150525123202_create_transactions.rb +20 -0
  187. data/db/migrate/20150526124755_create_settings.rb +16 -0
  188. data/db/migrate/20150603163451_add_cost_comment_collected_by_to_asset_repair_request.rb +7 -0
  189. data/db/migrate/20150605144111_collected.rb +5 -0
  190. data/db/migrate/20150609111725_add_column_notification.rb +5 -0
  191. data/db/migrate/20150609170014_create_user_notification_settings.rb +13 -0
  192. data/db/migrate/20150609175555_add_city_to_locations.rb +4 -0
  193. data/db/migrate/20150612190052_addcity.rb +5 -0
  194. data/db/migrate/20150614215015_create_members.rb +27 -0
  195. data/db/migrate/20150616070816_add_organization_to_schedules.rb +9 -0
  196. data/db/migrate/20150616114344_change_timestape_to_date.rb +4 -0
  197. data/db/migrate/20150619085555_add_index_repair_scan_to_repair.rb +6 -0
  198. data/db/migrate/20150623120915_create_depreciation_settings.rb +9 -0
  199. data/db/migrate/20150624060402_add_depriciation_ref_to_assets.rb +5 -0
  200. data/db/migrate/20150624085501_add_organization_ref_dep.rb +5 -0
  201. data/db/migrate/20150624114339_add_user_to_vacation_info.rb +9 -0
  202. data/db/migrate/20150624131422_change_dep_seeting.rb +6 -0
  203. data/db/migrate/20150625090838_add_dep_cost_col_in_assets.rb +5 -0
  204. data/db/migrate/20150626123545_add_vendor_id_to_asset.rb +5 -0
  205. data/db/migrate/20150629095216_add_depreciated_cost_asset.rb +5 -0
  206. data/db/migrate/20150629124325_add_allow_vendor_additon_to_setings.rb +7 -0
  207. data/db/migrate/20150630080925_add_approve_to_vendor.rb +5 -0
  208. data/db/migrate/20150630112252_add_referrenc_dereciation_to_asset.rb +5 -0
  209. data/db/migrate/20150630124838_add_ref_dep_organization.rb +5 -0
  210. data/db/migrate/20150707102850_add_column_sittings_to_delete_ticket.rb +6 -0
  211. data/db/migrate/20150710150314_add_org_ref_to_subdomain.rb +5 -0
  212. data/db/migrate/20150713204553_add_hire_dateto_member.rb +9 -0
  213. data/db/migrate/20150714004440_add_organization_to_notes.rb +9 -0
  214. data/db/migrate/20150714100444_add_time_format_to_member.rb +9 -0
  215. data/db/migrate/20150714202050_create_asset_tickets.rb +11 -0
  216. data/db/migrate/20150722151752_add_invitation_counts_to_user.rb +10 -0
  217. data/db/migrate/20150723141352_add_invitation_created_at_to_member.rb +10 -0
  218. data/db/migrate/20150724105130_create_projects.rb +8 -0
  219. data/db/migrate/20150724105257_create_project_payments.rb +13 -0
  220. data/db/migrate/20150724220844_add_user_index_to_asset.rb +6 -0
  221. data/db/migrate/20150727085046_add_projects_to_organization.rb +11 -0
  222. data/db/migrate/20150727122551_add_coloumn_to_vendors.rb +5 -0
  223. data/db/migrate/20150727211029_add_column_code_to_asset.rb +5 -0
  224. data/db/migrate/20150728101649_add_disabled_to_member.rb +9 -0
  225. data/db/migrate/20150731095354_add_column_repair_date_to_asset.rb +6 -0
  226. data/db/migrate/20150731104152_add_column_repair_reminder_setting.rb +5 -0
  227. data/db/migrate/20150806085559_create_member_devices.rb +10 -0
  228. data/db/migrate/20150807133155_add_view_to_alert.rb +9 -0
  229. data/db/migrate/20150808151840_app_col_in_member_device.rb +5 -0
  230. data/db/migrate/20150808180234_add_deleted_at_toalerts.rb +7 -0
  231. data/db/migrate/20150810110136_add_address_in_4_feilds_vendor.rb +12 -0
  232. data/db/migrate/20150810172933_change_column_type_in_vendors.rb +6 -0
  233. data/db/migrate/20150811061019_change_column_in_vendors.rb +5 -0
  234. data/db/migrate/20150811133002_change_shift_off_time.rb +5 -0
  235. data/db/migrate/20150811135657_change_column_type_timestamp_to_date.rb +7 -0
  236. data/db/migrate/20150818131207_create_history_emails.rb +10 -0
  237. data/db/migrate/20150820115042_change_schedule_total_hours.rb +6 -0
  238. data/db/migrate/20150820120309_add_column_email_remove.rb +5 -0
  239. data/db/migrate/20150820121702_add_column_email_organization.rb +5 -0
  240. data/db/migrate/20150824085019_add_column_asset_purchase_vendor.rb +5 -0
  241. data/db/migrate/20150826122944_add_column_exipry_notification.rb +5 -0
  242. data/db/migrate/20150827113937_create_members_roles.rb +9 -0
  243. data/db/migrate/20150828145913_add_locable_to_member.rb +7 -0
  244. data/db/migrate/20150903155708_add_vendor_feilds_to_user.rb +8 -0
  245. data/db/migrate/20150903200953_add_shift_to_candidate.rb +9 -0
  246. data/db/migrate/20150904082434_add_one_sided_to_trade_shift.rb +9 -0
  247. data/db/migrate/20150904134529_add_column_in_setting_user_dispatch.rb +5 -0
  248. data/db/migrate/20150907082501_add_website_for_vendor.rb +6 -0
  249. data/db/migrate/20150907141100_add_dollar_limit_to_user.rb +5 -0
  250. data/db/migrate/20150907193030_add_estimate_in_repair.rb +8 -0
  251. data/db/migrate/20150908123735_add_vendor_aproval_in_repair.rb +10 -0
  252. data/db/migrate/20150909112005_add_column_amount_into_plan.rb +5 -0
  253. data/db/migrate/20150916131512_add_plan_name_to_project_payment.rb +9 -0
  254. data/db/schema.rb +909 -0
  255. data/db/seeds.rb +23 -0
  256. data/lib/assets/.keep +0 -0
  257. data/lib/pshq_engine/version.rb +3 -0
  258. data/lib/pshq_engine.rb +5 -0
  259. data/lib/tasks/.keep +0 -0
  260. data/pshq_engine.gemspec +26 -0
  261. metadata +330 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ec27e1c0c1a5f0b2625dc69a028d79532e3a0ba8
4
+ data.tar.gz: c9ff0ca785cccae7028461142e935053f1c4440f
5
+ SHA512:
6
+ metadata.gz: cb61a3bb0ce662e8174b3a37e42307798b9ff4d788a45d60b34af49fe5d0ebfbd069b2b0a33d547685b7d58d9bbac354b05b310fcfe8b2c3531f312b5a6e68ca
7
+ data.tar.gz: 52318eac713c24208599f78d5d9fe0144c14318266c0e886b852cac5ec2bacc1125745a5268b9e5770098bfac2e6638d47372127a23a9c0bc1d05c703769718d
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /spec/reports/
7
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pshq_engine.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # PshqEngine
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pshq_engine`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'pshq_engine'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install pshq_engine
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/pshq_engine/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/app/models/.keep ADDED
File without changes
@@ -0,0 +1,76 @@
1
+ class Ability
2
+ include CanCan::Ability
3
+
4
+ def initialize(member)
5
+ # alias_action :index, :show, :update, :to => :manage_users
6
+ member ||= Member.new
7
+ if member.has_role? :employee
8
+ can :invite, User
9
+ can :index, Cancellation
10
+ can :index, Task
11
+ can :show, Cancellation
12
+ can :index, Job
13
+ can :update, Cancellation
14
+ can :cancel, Cancellation
15
+ can :index, Candidate
16
+ can :trade, Candidate
17
+ can :deny, Candidate
18
+
19
+ can :create, Feedback
20
+
21
+ can :manage, Message
22
+
23
+ can :manage, Mailboxer::Conversation
24
+
25
+ can :index, ShiftOff
26
+
27
+ can :create, Organization
28
+ can :index, Organization
29
+ can :save_employees, Organization
30
+ can :login_organization, Organization
31
+ can :select_org_member, Organization
32
+
33
+ can :published_schedules, Schedule
34
+ can :export, Schedule
35
+ can :overview, Schedule
36
+ can :email_export, Schedule
37
+ can :export_pdf, Schedule
38
+ can :editable_schedules, Schedule
39
+ # need further consideration on shift
40
+ can :manage, Shift
41
+
42
+ can :index, ShiftTrade
43
+ can :select, ShiftTrade
44
+
45
+ can :index, Swap
46
+ can :show, Swap
47
+ can :update, Swap
48
+ can :cancel, Swap
49
+
50
+ can :index, Timeoff do |t|
51
+ t.user_id == user.id
52
+ end
53
+ can :create, Timeoff
54
+ can :show, Timeoff
55
+ can :update, Timeoff
56
+ can :cancel, Timeoff
57
+ can :check_unique_date, Timeoff
58
+
59
+ # user part
60
+ can :profile, User do |u|
61
+ u.id = user.id
62
+ end
63
+
64
+ can :update, User do |u|
65
+ u.id = user.id
66
+ end
67
+
68
+ can :org_members, User do |u|
69
+ u.id = user.id
70
+ end
71
+ else
72
+ can :manage, :all
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,56 @@
1
+ class Alert < ActiveRecord::Base
2
+ acts_as_paranoid
3
+ after_create :notify_users
4
+ belongs_to :organization
5
+ belongs_to :user
6
+
7
+ def get_shift
8
+ if self.alert_type == "Time Off"
9
+ Timeoff.find_by_id(self.alert_type_id)
10
+ elsif self.alert_type == "Cancellation"
11
+ @cancellation = Cancellation.find_by_id(self.alert_type_id)
12
+ if !@cancellation.nil?
13
+ @cancellation.shift
14
+ end
15
+ elsif self.alert_type == "Late Notice"
16
+ @lateness = Lateness.find_by_id(self.alert_type_id)
17
+ if !@lateness.nil?
18
+ @lateness.shift
19
+ end
20
+ elsif self.alert_type == "Swap"
21
+ @swap = Swap.find_by_id(self.alert_type_id)
22
+ if !@swap.nil?
23
+ @swap.shift
24
+ end
25
+ elsif self.alert_type =="unavailable"
26
+ @unavailable = Unavailable.find_by_id(self.alert_type_id)
27
+ if !@unavailable.nil?
28
+ @unavailable.shift
29
+ end
30
+ elsif self.alert_type =="Fill Shift"
31
+ Shift.find_by_id(self.alert_type_id)
32
+ end
33
+ end
34
+
35
+ def get_shift_job
36
+ @swap = Swap.find_by_id(self.alert_type_id)
37
+ if !@swap.nil?
38
+ @swap.shift.job.name
39
+ end
40
+ end
41
+
42
+ def find_time_off
43
+ Timeoff.find_by_id(self.alert_type_id)
44
+ end
45
+
46
+ private
47
+
48
+ def notify_users
49
+ org_name = self.organization.name
50
+ org_name = org_name.gsub(" ", "_") if org_name.include?(" ")
51
+ Pusher.trigger(org_name, 'new-alert', {:message => ''})
52
+ end
53
+
54
+
55
+
56
+ end
@@ -0,0 +1,485 @@
1
+ class Asset < ActiveRecord::Base
2
+
3
+ acts_as_paranoid
4
+
5
+ self.per_page = 24
6
+ require 'will_paginate/array'
7
+ belongs_to :organization
8
+ belongs_to :location
9
+ belongs_to :depreciation_setting
10
+ belongs_to :user
11
+ has_many :asset_scans
12
+ has_one :manufacturer
13
+ has_many :images, :class_name => "AssetImage"
14
+ has_many :repair_requests, :class_name => "AssetRepairRequest"
15
+ has_many :notifications, :as => :source
16
+ has_many :asset_assignments
17
+ has_many :asset_codes
18
+
19
+ # validates :name, :presence => true
20
+
21
+
22
+ include PgSearch
23
+ pg_search_scope :custom_search,
24
+ :against => [:name, :description, :current_location, :model_no, :serial_no, :sku, :purchased_from, :info, :replace_priority, :retire],
25
+ :using => {
26
+ :tsearch => {:prefix => true}
27
+ }
28
+
29
+ multisearchable :against => [:name, :description, :current_location, :model_no, :serial_no, :sku, :purchased_from, :info, :replace_priority, :retire]
30
+
31
+
32
+ def self.filter_data(organization,page ,params)
33
+ if params == "All"
34
+ assets = organization.assets
35
+ elsif params == "true"
36
+ assets = organization.assets.where(:retire => true)
37
+ elsif params == "false"
38
+ assets = organization.assets.where(:retire => false)
39
+ elsif params == "unassg"
40
+ array_assigned = []
41
+ organization.assets.each do |aa|
42
+ if(aa.asset_assignments.count == 0)
43
+ array_assigned << aa
44
+ end
45
+ end
46
+ assets = array_assigned
47
+ elsif params == "assg"
48
+ array_unassigned = []
49
+ organization.assets.each do |aa|
50
+ if(aa.asset_assignments.count > 0)
51
+ array_unassigned << aa
52
+ end
53
+ end
54
+ assets = array_unassigned
55
+ end
56
+ assets
57
+ end
58
+
59
+
60
+
61
+ def self.decode_file(params,organization)
62
+ count=0
63
+ # decode base64 string
64
+
65
+ Rails.logger.info 'decoding base64 file'
66
+ decoded_data = Base64.decode64(params[:imp][:base64])
67
+ # create 'file' understandable by Paperclip
68
+ data = StringIO.new(decoded_data)
69
+ data.class_eval do
70
+ attr_accessor :content_type, :original_filename
71
+ end
72
+
73
+ # set file properties
74
+
75
+ data.content_type = params[:imp][:filetype]
76
+ data.original_filename = params[:imp][:filename]
77
+
78
+ new = Importfile.new(:avatar => data)
79
+
80
+ new.save
81
+
82
+ # open xlsx file
83
+ xlsx = Roo::Spreadsheet.open(new.avatar.url)
84
+ xlsx = Roo::Excelx.new(new.avatar.url)
85
+ xlsx.default_sheet = xlsx.sheets.first
86
+ # getting data from file in hash loop
87
+ xlsx.each_with_index(name: 'Name' ,
88
+ description: 'Description',
89
+ current_location: 'Current location',
90
+ is_new: 'New',
91
+ is_traded: 'Equipment traded',
92
+ electroic_need: 'Electric needs',
93
+ volts: 'volts',
94
+ model_no: 'Model number',
95
+ serial_no: 'Serial number',
96
+ sku: 'SKU',
97
+ manufactured_date: 'Date manufactured',
98
+ purchased_date: 'Date purchased',
99
+ purchased_from: 'Purchased from',
100
+ info: 'other info',
101
+ replace_priority: 'Replacement priority',
102
+ retire: 'Enable/Disable',
103
+
104
+ ) do |hash, i|
105
+ if i != 0
106
+ count=count+1
107
+ # Sending data to db-table
108
+ @asset = organization.assets.create(
109
+ :name => hash[:name],
110
+ :description => hash[:description],
111
+ :current_location => hash[:current_location],
112
+ :is_new => hash[:is_new],
113
+ :is_traded => hash[:is_traded],
114
+ :electroic_need => hash[:electroic_need],
115
+ :volts => hash[:volts],
116
+ :model_no => hash[:model_no],
117
+ :serial_no => hash[:serial_no],
118
+ :sku => hash[:sku],
119
+ :manufactured_date => hash[:manufactured_date],
120
+ :purchased_date => hash[:purchased_date],
121
+ :purchased_from => hash[:purchased_from],
122
+ :info => hash[:info],
123
+ :replace_priority => hash[:replace_priority],
124
+ :retire => hash[:retire]
125
+ )
126
+ end
127
+
128
+ end
129
+ count
130
+ end
131
+
132
+ def self.default_template(param,organization)
133
+
134
+ end
135
+
136
+ # def self.default_template(param,organization)
137
+ # # open xlsx file
138
+ # if param == 2
139
+ # path = "#{Rails.root}/app/assets/xlsx/Doctors.xlsx"
140
+ # elsif param == 3
141
+ # path = "#{Rails.root}/app/assets/xlsx/Beauty.xlsx"
142
+ # elsif param == 4
143
+ # path = "#{Rails.root}/app/assets/xlsx/Real.xlsx"
144
+ # else
145
+ # path = "#{Rails.root}/app/assets/xlsx/Default.xlsx"
146
+ # end
147
+ #
148
+ # xlsx = Roo::Spreadsheet.open(path)
149
+ # xlsx = Roo::Excelx.new(path)
150
+ # xlsx.default_sheet = xlsx.sheets.first
151
+ # # getting data from file in hash loop
152
+ # xlsx.each_with_index(name: 'Name' ,
153
+ # description: 'Description',
154
+ # current_location: 'Current location',
155
+ # is_new: 'New',
156
+ # is_traded: 'Equipment traded',
157
+ # electroic_need: 'Electric needs',
158
+ # volts: 'volts',
159
+ # model_no: 'Model number',
160
+ # serial_no: 'Serial number',
161
+ # sku: 'SKU',
162
+ # manufactured_date: 'Date manufactured',
163
+ # purchased_date: 'Date purchased',
164
+ # purchased_from: 'Purchased from',
165
+ # info: 'other info',
166
+ # replace_priority: 'Replacement priority',
167
+ # retire: 'Enable/Disable',
168
+ #
169
+ # ) do |hash, i|
170
+ # if i != 0
171
+ # # Sending data to db-table
172
+ # @asset = organization.assets.create(
173
+ # :name => hash[:name],
174
+ # :description => hash[:description],
175
+ # :current_location => hash[:current_location],
176
+ # :is_new => hash[:is_new],
177
+ # :is_traded => hash[:is_traded],
178
+ # :electroic_need => hash[:electroic_need],
179
+ # :volts => hash[:volts],
180
+ # :model_no => hash[:model_no],
181
+ # :serial_no => hash[:serial_no],
182
+ # :sku => hash[:sku],
183
+ # :manufactured_date => hash[:manufactured_date],
184
+ # :purchased_date => hash[:purchased_date],
185
+ # :purchased_from => hash[:purchased_from],
186
+ # :info => hash[:info],
187
+ # :replace_priority => hash[:replace_priority],
188
+ # :retire => hash[:retire]
189
+ # )
190
+ # end
191
+ # end
192
+ # count
193
+ # end
194
+ #
195
+
196
+
197
+ def upload(params)
198
+
199
+ decoded_data = Base64.decode64(params[:image][:base64])
200
+ data = StringIO.new(decoded_data)
201
+ data.class_eval do
202
+ attr_accessor :content_type, :original_filename
203
+ end
204
+ data.content_type = params[:image][:filetype]
205
+ data.original_filename = params[:image][:filename]
206
+
207
+ self.images.create(:asset_id => self.id, :image => data)
208
+
209
+ end
210
+
211
+ # Returns all repair tickets that are pending.
212
+ def pending_tickets
213
+ self.repair_requests.where({
214
+ status: 0
215
+ })
216
+ end
217
+ # Ticket in progress
218
+ def ticket_in_progress
219
+ self.repair_requests.where("status = ? or status = ? or status = ? ", 0 , 1 ,3)
220
+ end
221
+
222
+ def create_repair_request(requested_by, vendor, comments)
223
+ self.repair_requests.create({
224
+ requested_by: requested_by,
225
+ vendor: vendor,
226
+ comments: comments,
227
+ status: 0,
228
+ requested_date: Time.new
229
+ })
230
+ end
231
+
232
+ def send_for_repair(requested_by, vendor, comments ,cost)
233
+ self.repair_requests.create({
234
+ requested_by: requested_by,
235
+ responded_by: requested_by,
236
+ vendor: vendor,
237
+ comments: comments,
238
+ status: 1,
239
+ requested_date: Time.new,
240
+ responded_date: Time.new,
241
+ responder_comments: comments ,
242
+ estimate_by_user: cost
243
+ })
244
+ end
245
+
246
+ def current_location
247
+ if self.location
248
+ self.location.name
249
+ end
250
+ end
251
+
252
+ def current_type
253
+ type = DepreciationSetting.find_by_id(self.depreciation_settings_id)
254
+ type.name
255
+ end
256
+
257
+ def vending_cost
258
+ self.repair_requests.where.not(:vending_cost => nil).map(&:vending_cost).sum()
259
+ end
260
+
261
+ def repair_count
262
+ self.repair_requests.where("status != -1 AND status != 0").count()
263
+ end
264
+
265
+ def last_assignment
266
+ assignments = self.asset_assignments.order(:created_at)
267
+ assignments.last
268
+ end
269
+
270
+ def create_and_send_notification_asset(current_user, organization)
271
+ managers = organization.managers(current_user)
272
+ summary = "added a new asset: " + self.name
273
+ organization.push_notification_user("CA" , self, summary , current_user ,managers ,organization)
274
+
275
+ type ="asset create"
276
+ email_notify = UserNotificationSetting.email_setting(current_user.id)
277
+ if email_notify == "immediately"
278
+ seen = true
279
+ UserNotificationSetting.create_asset_email(self, organization ,organization.setting.from_email, current_user)
280
+ HistoryEmail.history_email(current_user.id ,type , seen,organization.id ,self.id)
281
+ else
282
+ seen= false
283
+ HistoryEmail.history_email(current_user.id ,type , seen,organization.id,self.id)
284
+ end
285
+ end
286
+
287
+ def calculate_repair_sum
288
+ repair = AssetRepairRequest.where(:asset_id => self.id, :status=> 2).map(&:vending_cost).compact.inject{|sum,x| sum.to_i + x.to_i }
289
+ repair.to_i
290
+ end
291
+
292
+ def cost_of_ownership
293
+ if calculate_repair_sum.to_i == 0
294
+ cost_of_ownership = purchased_cost.to_f
295
+ else
296
+ cost_of_ownership = purchased_cost.to_f + calculate_repair_sum.to_f
297
+ end
298
+ end
299
+
300
+ def get_vendor
301
+ User.find_by_id(self.vendor_id)
302
+ end
303
+
304
+ # Get purchase vendor for Asset details
305
+ def get_purchase_vendor
306
+ User.find_by_id(self.purchase_vendor_id)
307
+ end
308
+
309
+
310
+ def update_asset_notification(current_user, organization)
311
+ managers = organization.managers(current_user)
312
+ Notification.create_and_send_notification(
313
+ :type => "CA",
314
+ :source => self,
315
+ :summary => "updated an asset: " + self.name,
316
+ :notifier => current_user,
317
+ :managers => managers,
318
+ :organizationID => organization.id
319
+ )
320
+ end
321
+
322
+ # Asset code for print
323
+
324
+ def self.find_code(asset_id)
325
+ asset = self.find_by_id(asset_id)
326
+ return asset.code_number
327
+ end
328
+
329
+
330
+
331
+ # QR code implementation
332
+ def self.create_qrcode(total_number, asset_id , asset_number)
333
+ qrcode ={}
334
+ @asset_id = asset_id
335
+ random_string_qrcode = asset_number
336
+ @asset_ticket = AssetTicket.create(:qrcode => random_string_qrcode , :genratenumber =>random_string_qrcode , :asset_id => @asset_id)
337
+
338
+ (0..total_number-1).each do |number|
339
+ srand = SecureRandom.hex(6)
340
+ @qr = RQRCode::QRCode.new(random_string_qrcode, :size => 2, :level => :m )
341
+ png = @qr.to_img
342
+ png.resize(90, 90).save("app/assets/code/#{srand}.png")
343
+ qrcode.store(@qr,@asset_ticket.qrcode )
344
+ end
345
+
346
+ return qrcode
347
+ end
348
+
349
+ # Bar Code implementation
350
+ def self.create_barcode(total_ticket , asset , asset_number)
351
+ barcode = {}
352
+ random_string_qrcode = asset_number
353
+ @ticket = AssetTicket.create(:qrcode => random_string_qrcode , :genratenumber =>random_string_qrcode , :asset_id => asset)
354
+
355
+ (0..total_ticket-1).each do|number|
356
+ rand = SecureRandom.hex(6)
357
+ @barcode = Barby::Code128B.new(random_string_qrcode)
358
+ File.open("app/assets/code/#{rand}.png", 'w+'){|f|
359
+ f.write @barcode.to_png(:margin => 1, :xdim => 1, :height => 55)
360
+ }
361
+ image_url = "app/assets/code/#{rand}.png"
362
+ var = Rails.root + image_url
363
+ barcode.store(var,@ticket.qrcode )
364
+ end
365
+
366
+ return barcode
367
+ end
368
+
369
+ # Start: Getting All asset without date
370
+ def self.total_asset(organization_id)
371
+ self.where("organization_id =? ", organization_id)
372
+ end
373
+ # End:
374
+
375
+ # Total asset in organization
376
+ def self.all_asset(organization_id , start_date, end_date)
377
+ self.where("organization_id =? and created_at >= ? and created_at <= ? ", organization_id, start_date, end_date).count
378
+ end
379
+
380
+ # Getting asset for email
381
+ def self.get_asset(organization_id , asset_id)
382
+ self.find_by_id_and_organization_id(asset_id , organization_id)
383
+ end
384
+
385
+ # Find new asset added in organzation
386
+ def self.new_asset_add(organization_id, start_date, end_date)
387
+ asset_details ={}
388
+ assets = self.where("organization_id =? and created_at >= ? and created_at <= ? and retire =?", organization_id, start_date , end_date, false)
389
+
390
+ assets.each do |asset|
391
+ user = User.find_by_id(asset.user_id)
392
+ if user and user.first_name
393
+ asset_details.store(asset , user.first_name)
394
+ end
395
+ end
396
+
397
+ return asset_details
398
+ end
399
+
400
+ # Total retire asset
401
+ def self.total_retire (organization_id , start_date, end_date)
402
+
403
+ retired_details ={}
404
+ assets = self.where("organization_id =? and created_at >= ? and created_at <= ? and retire =?", organization_id,start_date, end_date, true)
405
+ assets.each do |asset|
406
+ user = User.find_by_id(asset.user_id)
407
+ if user and user.first_name
408
+ retired_details.store(asset , user.first_name)
409
+ else
410
+
411
+ end
412
+ end
413
+ return retired_details
414
+
415
+ end
416
+
417
+ #incomplete information
418
+ def self.info_incomplete(organization_id, start_date, end_date)
419
+
420
+ @asset = self.where("organization_id =? and created_at >= ? and created_at <= ? ", organization_id, start_date, end_date)
421
+ array_asset = []
422
+
423
+ @asset.each do |asset|
424
+ if asset.name.blank? or asset.purchased_date.blank? or asset.purchased_date.blank? or asset.vendor_id.blank? or asset.serial_no.blank? or asset.model_no.blank?
425
+ array_asset<< asset
426
+ end
427
+ end
428
+ return array_asset
429
+ end
430
+
431
+ # Start: Find Asset Reminder
432
+ def self.find_asset_reminder(reminder)
433
+
434
+ if reminder.blank?
435
+ re_time = 1.week
436
+ elsif reminder =="1_week"
437
+ re_time = 1.week
438
+ elsif reminder =="2_week"
439
+ re_time = 2.week
440
+ elsif reminder =="1_month"
441
+ re_time = 1.month
442
+ elsif reminder =="2_month"
443
+ re_time = 2.month
444
+ elsif reminder =="3_month"
445
+ re_time = 3.month
446
+ elsif reminder =="4_month"
447
+ re_time = 4.month
448
+ elsif reminder =="5_month"
449
+ re_time = 5.month
450
+ elsif reminder =="6_month"
451
+ re_time = 6.month
452
+ end
453
+ return re_time
454
+ end
455
+
456
+ #Email Subject Line not use current due subject line provide by static
457
+ def self.subjectline(asset)
458
+
459
+ if asset.repair_reminder.blank?
460
+ re_time = "1 week"
461
+ elsif asset.repair_reminder =="1_week"
462
+ re_time = "1 week"
463
+ elsif asset.repair_reminder =="2_week"
464
+ re_time = "2 week"
465
+ elsif asset.repair_reminder =="1_month"
466
+ re_time = "1 month"
467
+ elsif asset.repair_reminder =="2_month"
468
+ re_time = "2 months"
469
+ elsif asset.repair_reminder =="3_month"
470
+ re_time = "3 months"
471
+ elsif asset.repair_reminder =="4_month"
472
+ re_time = "4 months"
473
+ elsif asset.repair_reminder =="5_month"
474
+ re_time = "5 months"
475
+ elsif asset.repair_reminder =="6_month"
476
+ re_time = "6 months"
477
+ end
478
+ sb = re_time + " "+ "left for"+ " "+ asset.name+ " " +"repair due date."
479
+ return sb
480
+ end
481
+
482
+
483
+ end
484
+
485
+
@@ -0,0 +1,13 @@
1
+ class AssetAssignment < ActiveRecord::Base
2
+ belongs_to :organization
3
+ belongs_to :asset
4
+ belongs_to :employee
5
+ belongs_to :assigned_by, :class_name => "User"
6
+
7
+
8
+ # Assignmnt details for email
9
+ def self.get_assginment(assignment ,user_id)
10
+ self.find_by_id_and_assigned_by_id(assignment ,user_id)
11
+ end
12
+
13
+ end