redmine_crm 0.0.43 → 0.0.63

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 (65) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +1 -1
  3. data/app/controllers/redmine_crm_controller.rb +26 -0
  4. data/app/views/redmine_crm/_money.html.erb +44 -0
  5. data/app/views/redmine_crm/settings.html.erb +10 -0
  6. data/bitbucket-pipelines.yml +1 -8
  7. data/config/currency_iso.json +1 -1
  8. data/config/locales/cs.yml +13 -0
  9. data/config/locales/de.yml +13 -0
  10. data/config/locales/en.yml +13 -0
  11. data/config/locales/es.yml +13 -0
  12. data/config/locales/ru.yml +13 -0
  13. data/config/routes.rb +5 -0
  14. data/doc/CHANGELOG +92 -1
  15. data/lib/redmine_crm/acts_as_draftable/draft.rb +1 -1
  16. data/lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb +4 -2
  17. data/lib/redmine_crm/acts_as_priceable/rcrm_acts_as_priceable.rb +33 -0
  18. data/lib/redmine_crm/acts_as_taggable/rcrm_acts_as_taggable.rb +10 -3
  19. data/lib/redmine_crm/acts_as_taggable/tag_list.rb +1 -1
  20. data/lib/redmine_crm/acts_as_viewed/rcrm_acts_as_viewed.rb +1 -1
  21. data/lib/redmine_crm/acts_as_votable/rcrm_acts_as_votable.rb +1 -1
  22. data/lib/redmine_crm/acts_as_votable/votable.rb +2 -2
  23. data/lib/redmine_crm/compatibility/routing_mapper_patch.rb +27 -0
  24. data/lib/redmine_crm/currency/formatting.rb +5 -5
  25. data/lib/redmine_crm/currency.rb +28 -17
  26. data/lib/redmine_crm/engine.rb +4 -0
  27. data/lib/redmine_crm/helpers/calendars_helper.rb +22 -0
  28. data/lib/redmine_crm/helpers/external_assets_helper.rb +1 -0
  29. data/lib/redmine_crm/helpers/form_tag_helper.rb +12 -0
  30. data/lib/redmine_crm/hooks/views_layouts_hook.rb +12 -0
  31. data/lib/redmine_crm/liquid/drops/attachment_drop.rb +47 -0
  32. data/lib/redmine_crm/liquid/drops/issue_relations_drop.rb +41 -0
  33. data/lib/redmine_crm/liquid/drops/issues_drop.rb +54 -28
  34. data/lib/redmine_crm/liquid/drops/time_entries_drop.rb +1 -1
  35. data/lib/redmine_crm/liquid/filters/arrays.rb +1 -1
  36. data/lib/redmine_crm/liquid/filters/base.rb +36 -4
  37. data/lib/redmine_crm/money_helper.rb +15 -14
  38. data/lib/redmine_crm/patches/liquid_patch.rb +33 -0
  39. data/lib/redmine_crm/settings/money.rb +46 -0
  40. data/lib/redmine_crm/settings.rb +53 -0
  41. data/lib/redmine_crm/version.rb +1 -1
  42. data/lib/redmine_crm.rb +15 -2
  43. data/redmine_crm.gemspec +4 -2
  44. data/test/acts_as_draftable/rcrm_acts_as_draftable_test.rb +0 -1
  45. data/test/acts_as_taggable/rcrm_acts_as_taggable_test.rb +97 -92
  46. data/test/fixtures/attachments.yml +14 -0
  47. data/test/liquid/drops/attachment_drop_test.rb +15 -0
  48. data/test/liquid/drops/issue_relations_drop_test.rb +24 -0
  49. data/test/liquid/drops/issues_drop_test.rb +4 -0
  50. data/test/liquid/filters/base_filter_test.rb +5 -1
  51. data/test/models/attachment.rb +3 -0
  52. data/test/models/issue.rb +7 -0
  53. data/test/models/issue_relation.rb +10 -0
  54. data/test/money_helper_test.rb +1 -1
  55. data/test/schema.rb +22 -1
  56. data/test/tags_helper_test.rb +4 -4
  57. data/vendor/assets/images/money.png +0 -0
  58. data/vendor/assets/javascripts/select2.js +2 -3
  59. data/vendor/assets/javascripts/select2_helpers.js +8 -2
  60. data/vendor/assets/javascripts/timepicker_addon.js +5 -0
  61. data/vendor/assets/stylesheets/calendars.css +15 -0
  62. data/vendor/assets/stylesheets/money.css +3 -0
  63. data/vendor/assets/stylesheets/select2.css +28 -18
  64. data/vendor/assets/stylesheets/timepicker_addon.css +5 -0
  65. metadata +57 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c7ec4763f7c0ff9e5ce0744bcd8579020ed89b32
4
- data.tar.gz: 45d4f87a91b17c299097c1f6aa5a9732507f30cc
2
+ SHA256:
3
+ metadata.gz: d6f025a0e487391530abd90ac50a2e4eae82f8f7dfe2a111b94fdf5bee72e49c
4
+ data.tar.gz: f4b6416ab62493a9909739545c70ec32ec22334409e07bf1270d6127a1149fcf
5
5
  SHA512:
6
- metadata.gz: a604d13c92a5a5e47ff93d7aeb3867c503c1743beb55059502cbc4fd28a2ddadac9e6cc7745e950249aace899dab2ed8e86d7ced27d5682bd2aade9f7c6e6ca3
7
- data.tar.gz: d26992ff800bf72702248dd3d3afb416ee15a5432091ed38befa56196a436b75901fc04a328dc742450261d1e59dba55552e33c8a32e985e6834fada408c79dc
6
+ metadata.gz: dd9eb904c28266a1d335f7b797c107686d74661bde31dee567de54c1aed2f556721b18621c1b2a03607f129d698e6b46525a325b5ca33c27663b7bce281c1b6a
7
+ data.tar.gz: c8e0342ed8a4f60fc7bb56d4e7b91d4e19f5b677fcb88f8f5dbe196515f86139a98c4f48ad003e3061b0b066fdac46c25128d4fc8889711cb70e2a6f68858a25
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in redmine_crm.gemspec
4
- gemspec
4
+ gemspec
@@ -0,0 +1,26 @@
1
+ class RedmineCrmController < ApplicationController
2
+ layout 'admin'
3
+
4
+ before_action :require_admin
5
+ require_sudo_mode :settings if respond_to?(:require_sudo_mode)
6
+
7
+ def settings
8
+ @section = RedmineCrm::Settings::SECTIONS[params[:id]]
9
+ return render_404 unless @section
10
+
11
+ if request.post?
12
+ setting =
13
+ if params[:settings].present?
14
+ params[:settings].respond_to?(:to_unsafe_hash) ? params[:settings].to_unsafe_hash : params[:settings]
15
+ else
16
+ {}
17
+ end
18
+ RedmineCrm::Settings.apply = setting
19
+ flash[:notice] = l(:notice_successful_update)
20
+ redirect_to redmine_crm_settings_path(@section[:id])
21
+ else
22
+ @settings = RedmineCrm::Settings.values
23
+ end
24
+ @section_tabs = RedmineCrm::Settings::SECTIONS.map { |_n, s| { name: s[:id], partial: s[:partial], label: s[:label] } }
25
+ end
26
+ end
@@ -0,0 +1,44 @@
1
+ <p>
2
+ <label for="cb_settings_disable_taxes"><%= l(:label_redmine_crm_disable_taxes) %></label>
3
+ <%= hidden_field_tag 'settings[disable_taxes]', '0' %>
4
+ <%= check_box_tag 'settings[disable_taxes]', 1, RedmineCrm::Settings::Money.disable_taxes?, id: 'cb_settings_disable_taxes' %>
5
+ </p>
6
+
7
+ <span id="tax_data">
8
+ <p>
9
+ <label><%= l(:label_redmine_crm_default_tax) %></label>
10
+ <%= text_field_tag 'settings[default_tax]', RedmineCrm::Settings::Money.default_tax, size: 6, maxlength: 5 %> %
11
+ </p>
12
+
13
+ <p>
14
+ <label><%= l(:label_redmine_crm_tax_type) %></label>
15
+ <%= select_tag 'settings[tax_type]', options_for_select([[l(:label_redmine_crm_tax_type_exclusive), RedmineCrm::Settings::Money::TAX_TYPE_EXCLUSIVE],
16
+ [l(:label_redmine_crm_tax_type_inclusive), RedmineCrm::Settings::Money::TAX_TYPE_INCLUSIVE]],
17
+ @settings['tax_type']) %>
18
+ </p>
19
+ </span>
20
+
21
+ <p>
22
+ <label><%= l(:label_redmine_crm_default_currency) %></label>
23
+ <%= select_tag 'settings[default_currency]', options_for_select(all_currencies.insert(0, ['', '']), RedmineCrm::Settings::Money.default_currency) %>
24
+ </p>
25
+
26
+ <p>
27
+ <label><%= l(:label_redmine_crm_major_currencies) %></label>
28
+ <%= text_field_tag 'settings[major_currencies]', RedmineCrm::Settings::Money.major_currencies.join(', '), size: 40 %>
29
+ <br>
30
+ <em class="info"><%= l(:text_comma_separated) %></em>
31
+ </p>
32
+
33
+ <p>
34
+ <label><%= l(:label_redmine_crm_thousands_delimiter) %></label>
35
+ <%= select_tag 'settings[thousands_delimiter]', options_for_select([["9 999", " "],
36
+ ["9,999", ","],
37
+ ["9.999", "."]], RedmineCrm::Settings::Money.thousands_delimiter) %>
38
+ </p>
39
+
40
+ <p>
41
+ <label><%= l(:label_redmine_crm_decimal_separator) %></label>
42
+ <%= select_tag 'settings[decimal_separator]', options_for_select([["0.00", "."],
43
+ ["0,00", ","]], RedmineCrm::Settings::Money.decimal_separator) %>
44
+ </p>
@@ -0,0 +1,10 @@
1
+ <%= title l(:label_redmine_crm_settings) %>
2
+
3
+ <div id="settings">
4
+ <%= form_tag({ action: 'settings', id: @section[:id] }) do %>
5
+ <div class="box tabular settings">
6
+ <%= render partial: 'money' %>
7
+ </div>
8
+ <%= submit_tag l(:button_apply) %>
9
+ <% end %>
10
+ </div>
@@ -12,6 +12,7 @@ pipelines:
12
12
  script:
13
13
  - sed -i "s/'sqlite3'/'sqlite3', '~> 1.3.6'/g" redmine_crm.gemspec
14
14
  - sed -i "s/'mysql2'/'mysql2', '~> 0.4.0'/g" redmine_crm.gemspec
15
+ - sed -i "s/'rubyzip'/'rubyzip'\n spec.add_runtime_dependency 'loofah', '~>2.19.1'/g" redmine_crm.gemspec
15
16
  - bundle install
16
17
  - bundle exec rake test DB=sqlite
17
18
  - bundle exec rake test DB=postgresql
@@ -19,14 +20,6 @@ pipelines:
19
20
  services:
20
21
  - mysql
21
22
  - postgres
22
- - step:
23
- name: Old ruby
24
- image: ruby:1.9.3
25
- script:
26
- - bundle install
27
- - bundle exec rake test DB=mysql
28
- services:
29
- - mysql
30
23
 
31
24
  definitions:
32
25
  services:
@@ -1813,7 +1813,7 @@
1813
1813
  "priority": 100,
1814
1814
  "iso_code": "RUB",
1815
1815
  "name": "Russian Ruble",
1816
- "symbol": "RUB",
1816
+ "symbol": "",
1817
1817
  "alternate_symbols": ["руб.", "р."],
1818
1818
  "subunit": "Kopeck",
1819
1819
  "subunit_to_unit": 100,
@@ -0,0 +1,13 @@
1
+ cs:
2
+ label_redmine_crm_settings: Peníze
3
+ label_redmine_crm_money: Peníze
4
+
5
+ label_redmine_crm_disable_taxes: Znemožnit daně
6
+ label_redmine_crm_default_tax: Výchozí hodnota daně
7
+ label_redmine_crm_tax_type: Typ daně
8
+ label_redmine_crm_tax_type_exclusive: Bez daně
9
+ label_redmine_crm_tax_type_inclusive: Včetně daně
10
+ label_redmine_crm_default_currency: Výchozí měna
11
+ label_redmine_crm_major_currencies: Hlavní měny
12
+ label_redmine_crm_thousands_delimiter: Oddělovač tisíců
13
+ label_redmine_crm_decimal_separator: Desetinný oddělovač
@@ -0,0 +1,13 @@
1
+ de:
2
+ label_redmine_crm_settings: Währungseinstellungen
3
+ label_redmine_crm_money: Währung
4
+
5
+ label_redmine_crm_disable_taxes: Steuern deaktiviert
6
+ label_redmine_crm_default_tax: Standard Steuersatz
7
+ label_redmine_crm_tax_type: Steuerart
8
+ label_redmine_crm_tax_type_exclusive: Steuer ausgeschlossen
9
+ label_redmine_crm_tax_type_inclusive: Steuer eingeschlossen
10
+ label_redmine_crm_default_currency: Standard Währung
11
+ label_redmine_crm_major_currencies: Aktive Währungen
12
+ label_redmine_crm_thousands_delimiter: Tausendertrennzeichen
13
+ label_redmine_crm_decimal_separator: Dezimaltrennzeichen
@@ -0,0 +1,13 @@
1
+ en:
2
+ label_redmine_crm_settings: Money Settings
3
+ label_redmine_crm_money: Money
4
+
5
+ label_redmine_crm_disable_taxes: Disable taxes
6
+ label_redmine_crm_default_tax: Default tax value
7
+ label_redmine_crm_tax_type: Tax type
8
+ label_redmine_crm_tax_type_exclusive: Tax exclusive
9
+ label_redmine_crm_tax_type_inclusive: Tax inclusive
10
+ label_redmine_crm_default_currency: Default currency
11
+ label_redmine_crm_major_currencies: Major currencies
12
+ label_redmine_crm_thousands_delimiter: Thousands delimiter
13
+ label_redmine_crm_decimal_separator: Decimal separator
@@ -0,0 +1,13 @@
1
+ es:
2
+ label_redmine_crm_settings: Configuración
3
+ label_redmine_crm_money: Dinero
4
+
5
+ label_redmine_crm_disable_taxes: Deshabilitar impuestos
6
+ label_redmine_crm_default_tax: Impuesto por defecto
7
+ label_redmine_crm_tax_type: Tipo de impuesto
8
+ label_redmine_crm_tax_type_exclusive: Excluir
9
+ label_redmine_crm_tax_type_inclusive: Incluir
10
+ label_redmine_crm_default_currency: Moneda por defecto
11
+ label_redmine_crm_major_currencies: Monedas usadas
12
+ label_redmine_crm_thousands_delimiter: Separador de miles
13
+ label_redmine_crm_decimal_separator: Separador de decimales
@@ -0,0 +1,13 @@
1
+ ru:
2
+ label_redmine_crm_settings: Настройки валют
3
+ label_redmine_crm_money: Деньги
4
+
5
+ label_redmine_crm_disable_taxes: Отключить налоги
6
+ label_redmine_crm_default_tax: Ставка налога
7
+ label_redmine_crm_tax_type: Тип налога
8
+ label_redmine_crm_tax_type_exclusive: Налог добавлен к общей сумме
9
+ label_redmine_crm_tax_type_inclusive: Налог включен с общую сумму
10
+ label_redmine_crm_default_currency: Валюта по умолчанию
11
+ label_redmine_crm_major_currencies: Основные валюты
12
+ label_redmine_crm_thousands_delimiter: Разделитель разрядов
13
+ label_redmine_crm_decimal_separator: Десятичный разделитель
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ match 'redmine_crm/settings/:id', to: 'redmine_crm#settings', as: 'redmine_crm_settings', via: [:get, :post]
5
+ end
data/doc/CHANGELOG CHANGED
@@ -1,9 +1,100 @@
1
1
  == Redmine CRM gem changelog
2
2
 
3
3
  Redmine crm gem - general functions for plugins (tags, vote, viewing, currency)
4
- Copyright (C) 2011-2019 RedmineUP
4
+ Copyright (C) 2011-2023 RedmineUP
5
5
  https://www.redmineup.com/
6
+
7
+ == 2023-12-26 v0.0.63
8
+
9
+ * Compatibility fixes with attachment routes
10
+
11
+ == 2023-11-15 v0.0.62
12
+
13
+ * Redmine 5.1 compatibility fixes
14
+
15
+ == 2023-09-27 v0.0.61
16
+
17
+ * Reverted time picker calendar
18
+ * Added helper methods for time format
19
+
20
+ == 2023-09-20 v0.0.60
21
+
22
+ * Fixed SQL injection
23
+ * Added calendar with date time picker
24
+
25
+ == 2023-01-16 v0.0.59
26
+
27
+ * Fixed attachments constraint
28
+ * Added Spanish locale (Juan José Taguas Navarro)
6
29
 
30
+ == 2022-09-26 v0.0.58
31
+
32
+ * Added closed? method to Issue Drop
33
+ * Added blank issue for Time Entry
34
+ * Added helpdesk_ticket method for Issue Drop
35
+
36
+ == 2022-02-14 v0.0.57
37
+
38
+ * Fixed BigDecimal liquid bug for ruby > 2.6
39
+
40
+ == 2022-02-14 v0.0.56
41
+
42
+ * Added rcrm_acts_as_priceable
43
+ * Added IssueRealtions drops
44
+
45
+ == 2021-06-08 v0.0.55
46
+
47
+ * Added Attachment Liquid drop
48
+ * Added section to Checklist Liquid drop
49
+ * Added Czech locale
50
+ * Added German locale
51
+
52
+ == 2020-08-10 v0.0.54
53
+
54
+ * Fixed new JQuery select2 bug
55
+
56
+ == 2020-04-07 v0.0.53
57
+
58
+ * Multiselect styles cleanup
59
+ * Added rubyzip dependence
60
+
61
+ == 2019-12-26 v0.0.52
62
+
63
+ * select2 styles cleanup
64
+
65
+ == 2019-12-20 v0.0.51
66
+
67
+ * Changed drafts params
68
+ * Changed Money settings UI
69
+ * Fixed bug with settings access
70
+
71
+ == 2019-11-18 v0.0.50
72
+
73
+ * Fixed bug with settings initialization
74
+
75
+ == 2019-11-12 v0.0.49
76
+
77
+ * Fixed settings compatibility bug
78
+
79
+ == 2019-11-07 v0.0.48
80
+
81
+ * Added global money setting
82
+ * Fixed select2 format
83
+
84
+ == 2019-08-26 v0.0.47
85
+
86
+ * Fixed bug with tag cloud
87
+
88
+ == 2019-08-14 v0.0.46
89
+
90
+ * select2 update
91
+
92
+ == 2019-08-13 v0.0.44
93
+
94
+ * Fixed Safari scroll down bug
95
+ * Multiaddress select helpers fixes
96
+ * Fixed tags privacy bugs
97
+
7
98
  == 2019-05-07 v0.0.43
8
99
 
9
100
  * custom_field and custom_fields methods added from Reporter plugin
@@ -24,7 +24,7 @@ module RedmineCrm
24
24
  module ActsAsDraftable
25
25
  class Draft < ActiveRecord::Base
26
26
  belongs_to :user
27
- belongs_to :parent, polymorphic: true
27
+ belongs_to :parent, polymorphic: true, autosave: false
28
28
 
29
29
  validates_presence_of :data, :target_type
30
30
 
@@ -78,8 +78,10 @@ module RedmineCrm
78
78
  target
79
79
  end
80
80
 
81
- def drafts(user)
82
- Draft.where(user_id: user.id, target_type: name)
81
+ def drafts(user = nil)
82
+ drafts = Draft.where(target_type: name)
83
+ drafts = drafts.where(user_id: user.id) if user
84
+ drafts
83
85
  end
84
86
  end # ClassMethods
85
87
 
@@ -0,0 +1,33 @@
1
+ module RedmineCrm
2
+ module ActsAsPriceable
3
+ module Base
4
+ def rcrm_acts_as_priceable(*args)
5
+ priceable_options = args
6
+ priceable_options << :price if priceable_options.empty?
7
+ priceable_methods = ""
8
+ priceable_options.each do |priceable_attr|
9
+ priceable_methods << %(
10
+ def #{priceable_attr.to_s}_to_s
11
+ object_price(
12
+ self,
13
+ :#{priceable_attr},
14
+ {
15
+ :decimal_mark => RedmineCrm::Settings::Money.decimal_separator,
16
+ :thousands_separator => RedmineCrm::Settings::Money.thousands_delimiter
17
+ }
18
+ ) if self.respond_to?(:#{priceable_attr})
19
+ end
20
+ )
21
+ end
22
+
23
+ class_eval <<-EOV
24
+ include RedmineCrm::MoneyHelper
25
+
26
+ #{priceable_methods}
27
+ EOV
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ ActiveRecord::Base.extend RedmineCrm::ActsAsPriceable::Base
@@ -90,7 +90,7 @@ module RedmineCrm
90
90
  #Return all avalible tags for a project or global
91
91
  #Example: Question.available_tags(:project => @project_id )
92
92
  def available_tags(options = {})
93
- project = options[:project]
93
+ projects = [[options[:project]], options[:projects]].flatten.compact
94
94
  limit = options[:limit].to_i.zero? ? 30 : options[:limit].to_i
95
95
  scope = Tag.where({})
96
96
  class_name = quote_string_value(base_class.name)
@@ -98,9 +98,9 @@ module RedmineCrm
98
98
  join << "JOIN #{Tagging.table_name} ON #{Tagging.table_name}.tag_id = #{Tag.table_name}.id "
99
99
  join << "JOIN #{table_name} ON #{table_name}.id = #{Tagging.table_name}.taggable_id
100
100
  AND #{Tagging.table_name}.taggable_type = #{class_name} "
101
- if attribute_names.include?('project_id') && project
101
+ if attribute_names.include?('project_id') && projects.any?
102
102
  join << "JOIN #{Project.table_name} ON #{Project.table_name}.id = #{table_name}.project_id"
103
- scope = scope.where("#{table_name}.project_id = ?", project.id)
103
+ scope = scope.where("#{table_name}.project_id IN (%s)", projects.map(&:id).join(','))
104
104
  end
105
105
 
106
106
  if options[:name_like]
@@ -111,6 +111,13 @@ module RedmineCrm
111
111
  group_fields << ", #{Tag.table_name}.created_at" if Tag.respond_to?(:created_at)
112
112
  group_fields << ", #{Tag.table_name}.updated_at" if Tag.respond_to?(:updated_at)
113
113
 
114
+ if base_class.respond_to?(:visible_condition)
115
+ visible_condition = base_class.visible_condition(User.current)
116
+ if visible_condition.include?('project_id') && join.all? { |jn| jn.exclude?('JOIN projects') }
117
+ join << "JOIN #{Project.table_name} ON #{Project.table_name}.id = #{table_name}.project_id"
118
+ end
119
+ scope = scope.where(visible_condition)
120
+ end
114
121
  scope = scope.joins(join.join(' '))
115
122
  scope = scope.select("#{Tag.table_name}.*, COUNT(DISTINCT #{Tagging.table_name}.taggable_id) AS count")
116
123
  scope = scope.group("#{Tag.table_name}.id, #{Tag.table_name}.name #{group_fields}")
@@ -58,7 +58,7 @@ module RedmineCrm
58
58
 
59
59
  map do |name|
60
60
  name.include?(delimiter) ? "\"#{name}\"" : name
61
- end.join(delimiter.ends_with?(" ") ? delimiter : "#{delimiter} ")
61
+ end.join(delimiter[-1] == (' ') ? delimiter : "#{delimiter} ")
62
62
  end
63
63
 
64
64
  private
@@ -183,7 +183,7 @@ module RedmineCrm
183
183
  if viewer && !viewer.id.nil? && !viewer.anonymous?
184
184
  return viewings.where("viewer_id = '#{viewer.id}'").any?
185
185
  else
186
- return viewings.where("ip = '#{ip}'").any?
186
+ return viewings.where("ip = :ip", ip: ip).any?
187
187
  end
188
188
  end
189
189
 
@@ -58,7 +58,7 @@ module RedmineCrm
58
58
 
59
59
  end
60
60
 
61
- if self.parent::VERSION::MAJOR < 4
61
+ if ::ActiveRecord::VERSION::MAJOR < 4
62
62
  create_index votes_name_table, [:votable_id, :votable_type, :vote_ip]
63
63
  create_index votes_name_table, [:voter_id, :voter_type, :vote_ip]
64
64
  end
@@ -233,9 +233,9 @@ module RedmineCrm
233
233
  end
234
234
  self.record_timestamps = false
235
235
  if (::ActiveRecord::VERSION::MAJOR == 3) && (::ActiveRecord::VERSION::MINOR != 0)
236
- self.update_attributes(updates, :without_protection => true) if !updates.empty?
236
+ self.assign_attributes(updates, :without_protection => true) && self.save if !updates.empty?
237
237
  else
238
- self.update_attributes(updates) if !updates.empty?
238
+ self.assign_attributes(updates) && self.save if !updates.empty?
239
239
  end
240
240
  end
241
241
 
@@ -0,0 +1,27 @@
1
+ module RedmineCrm
2
+ module Patches
3
+ module RoutingMapperPatch
4
+ def self.included(base)
5
+ base.send(:include, InstanceMethods)
6
+
7
+ base.class_eval do
8
+ alias_method :constraints_without_redmine_crm, :constraints
9
+ alias_method :constraints, :constraints_with_redmine_crm
10
+ end
11
+ end
12
+
13
+ module InstanceMethods
14
+ def constraints_with_redmine_crm(options = {}, &block)
15
+ return constraints_without_redmine_crm(options, &block) unless options.is_a?(Hash)
16
+
17
+ options[:object_type] = /.+/ if options[:object_type] && options[:object_type].is_a?(Regexp)
18
+ constraints_without_redmine_crm(options, &block)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ unless ActionDispatch::Routing::Mapper.included_modules.include?(RedmineCrm::Patches::RoutingMapperPatch)
26
+ ActionDispatch::Routing::Mapper.send(:include, RedmineCrm::Patches::RoutingMapperPatch)
27
+ end
@@ -4,8 +4,8 @@ module RedmineCrm
4
4
  module Formatting
5
5
  def self.included(base)
6
6
  [
7
- [:thousands_separator, :delimiter, ","],
8
- [:decimal_mark, :separator, "."]
7
+ [:thousands_separator, :delimiter, RedmineCrm::Settings::Money.thousands_delimiter],
8
+ [:decimal_mark, :separator, RedmineCrm::Settings::Money.decimal_separator]
9
9
  ].each do |method, name, character|
10
10
  define_i18n_method(method, name, character)
11
11
  end
@@ -115,9 +115,9 @@ module RedmineCrm
115
115
 
116
116
  def default_formatting_rules
117
117
  {
118
- :decimal_mark =>".",
119
- :thousands_separator => ",",
120
- :subunit_to_unit => 100
118
+ decimal_mark: RedmineCrm::Settings::Money.decimal_separator || '.',
119
+ thousands_separator: RedmineCrm::Settings::Money.thousands_delimiter || ',',
120
+ subunit_to_unit: 100
121
121
  }
122
122
  end
123
123
 
@@ -33,6 +33,17 @@ module RedmineCrm
33
33
 
34
34
  class << self
35
35
 
36
+ def add_admin_money_menu
37
+ return if Redmine::MenuManager.map(:admin_menu).exists?(:redmine_crm_money)
38
+
39
+ require 'redmine_crm/hooks/views_layouts_hook'
40
+ Redmine::MenuManager.map(:admin_menu).push(:redmine_crm_money,
41
+ { controller: 'redmine_crm', action: 'settings', id: 'money' },
42
+ caption: :label_redmine_crm_money,
43
+ html: { class: 'icon icon-redminecrm-money' })
44
+
45
+ end
46
+
36
47
  # Lookup a currency with given +id+ an returns a +Currency+ instance on
37
48
  # success, +nil+ otherwise.
38
49
  #
@@ -190,40 +201,40 @@ module RedmineCrm
190
201
  end
191
202
  end
192
203
 
193
- # @!attribute [r] id
204
+ # @!attribute [r] id
194
205
  # @return [Symbol] The symbol used to identify the currency, usually THE
195
206
  # lowercase +iso_code+ attribute.
196
- # @!attribute [r] priority
207
+ # @!attribute [r] priority
197
208
  # @return [Integer] A numerical value you can use to sort/group the
198
209
  # currency list.
199
- # @!attribute [r] iso_code
210
+ # @!attribute [r] iso_code
200
211
  # @return [String] The international 3-letter code as defined by the ISO
201
212
  # 4217 standard.
202
- # @!attribute [r] iso_numeric
213
+ # @!attribute [r] iso_numeric
203
214
  # @return [String] The international 3-numeric code as defined by the ISO
204
215
  # 4217 standard.
205
- # @!attribute [r] name
216
+ # @!attribute [r] name
206
217
  # @return [String] The currency name.
207
- # @!attribute [r] symbol
218
+ # @!attribute [r] symbol
208
219
  # @return [String] The currency symbol (UTF-8 encoded).
209
- # @!attribute [r] disambiguate_symbol
220
+ # @!attribute [r] disambiguate_symbol
210
221
  # @return [String] Alternative currency used if symbol is ambiguous
211
- # @!attribute [r] html_entity
222
+ # @!attribute [r] html_entity
212
223
  # @return [String] The html entity for the currency symbol
213
- # @!attribute [r] subunit
224
+ # @!attribute [r] subunit
214
225
  # @return [String] The name of the fractional monetary unit.
215
- # @!attribute [r] subunit_to_unit
226
+ # @!attribute [r] subunit_to_unit
216
227
  # @return [Integer] The proportion between the unit and the subunit
217
- # @!attribute [r] decimal_mark
228
+ # @!attribute [r] decimal_mark
218
229
  # @return [String] The decimal mark, or character used to separate the
219
230
  # whole unit from the subunit.
220
- # @!attribute [r] The
231
+ # @!attribute [r] The
221
232
  # @return [String] character used to separate thousands grouping of the
222
233
  # whole unit.
223
- # @!attribute [r] symbol_first
234
+ # @!attribute [r] symbol_first
224
235
  # @return [Boolean] Should the currency symbol precede the amount, or
225
236
  # should it come after?
226
- # @!attribute [r] smallest_denomination
237
+ # @!attribute [r] smallest_denomination
227
238
  # @return [Integer] Smallest amount of cash possible (in the subunit of
228
239
  # this currency)
229
240
 
@@ -301,7 +312,7 @@ module RedmineCrm
301
312
  end
302
313
  self.id.to_s.downcase == other_currency_id
303
314
  end
304
-
315
+
305
316
  private :compare_ids
306
317
 
307
318
  # Returns a Fixnum hash value based on the +id+ attribute in order to use
@@ -402,7 +413,7 @@ module RedmineCrm
402
413
  end
403
414
 
404
415
  private
405
-
416
+
406
417
  def cache
407
418
  self.class.decimal_places_cache
408
419
  end
@@ -436,4 +447,4 @@ module RedmineCrm
436
447
  @thousands_separator = data[:thousands_separator]
437
448
  end
438
449
  end
439
- end
450
+ end
@@ -0,0 +1,4 @@
1
+ module RedmineCrm
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,22 @@
1
+ module RedmineCrm
2
+ module CalendarsHelper
3
+
4
+ def calendar_day_css_classes(calendar, day)
5
+ css = day.month==calendar.month ? +'even' : +'odd'
6
+ css << " today" if User.current.today == day
7
+ css << " nwday" if non_working_week_days.include?(day.cwday)
8
+ css
9
+ end
10
+
11
+ def non_working_week_days
12
+ @non_working_week_days ||= begin
13
+ days = Setting.non_working_week_days
14
+ if days.is_a?(Array) && days.size < 7
15
+ days.map(&:to_i)
16
+ else
17
+ []
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -15,5 +15,6 @@ module RedmineCrm
15
15
  @chartjs_tag_included = true
16
16
  javascript_include_tag('Chart.bundle.min', plugin: GEM_NAME)
17
17
  end
18
+
18
19
  end
19
20
  end
@@ -72,5 +72,17 @@ module RedmineCrm
72
72
  def transform_to_select2(type, options = {})
73
73
  javascript_tag("setSelect2Filter('#{type}', #{options.to_json});") unless type.empty?
74
74
  end
75
+
76
+ def format_datetime(time)
77
+ formated_time = format_time(time, false)
78
+ formated_date = ::I18n.l(time.to_date, format: '%Y-%m-%d')
79
+ "#{formated_date} #{formated_time}"
80
+ end
81
+
82
+ def format_datetime_date(time)
83
+ formated_date = ::I18n.l(time.to_date, format: '%Y-%m-%d')
84
+ "#{formated_date}"
85
+ end
86
+
75
87
  end
76
88
  end