Commit 79485323b229cbe5146dcc1c1461ecefb51fa1f7
1 parent
8fabfb85
Exists in
master
and in
28 other branches
[bsc-contracts] Views, css and js
(ActionItem2079)
Showing
14 changed files
with
487 additions
and
73 deletions
Show diff stats
@@ -0,0 +1,86 @@ | @@ -0,0 +1,86 @@ | ||
1 | +var BSCContracts = {}; | ||
2 | + | ||
3 | +(function($){ | ||
4 | + BSCContracts.onDelete = function(item){ | ||
5 | + $('.token-input-dropdown').hide(); | ||
6 | + $('#bsc-plugin-row-'+item.sale_id.toString()).remove(); | ||
7 | + BSCContracts.updateTotal(); | ||
8 | + }; | ||
9 | + | ||
10 | + BSCContracts.onAdd = function(item){ | ||
11 | + var quantity = $('#bsc-plugin-sale-'+item.sale_id.toString()+'-quantity'); | ||
12 | + var price = $('#bsc-plugin-sale-'+item.sale_id.toString()+'-price'); | ||
13 | + quantity.addClass('required'); | ||
14 | + price.addClass('required'); | ||
15 | + quantity.val(1); | ||
16 | + price.val(item.product_price); | ||
17 | + BSCContracts.updateTotal(); | ||
18 | + }; | ||
19 | + | ||
20 | + BSCContracts.newID = function(){ | ||
21 | + if ( !this.idNum ) this.idNum = 0; | ||
22 | + return this.idNum++; | ||
23 | + }; | ||
24 | + | ||
25 | + BSCContracts.newProductLine = function(item){ | ||
26 | + var id = this.newID(); | ||
27 | + var tr = $('<tr class="bsc-plugin-sales-product" id="bsc-plugin-row-'+id+'"></tr>'); | ||
28 | + var tds = $('<td></td><td></td><td>'+this.currencyUnit+'</td>').appendTo(tr); | ||
29 | + var input = $('<input name="sales['+id+'][product_id]" class="search-product-field"/>').appendTo(tds[0]); | ||
30 | + var searchUrl = this.searchUrl | ||
31 | + .replace('ENTERPRISES', $('#involved-enterprises').val()) | ||
32 | + .replace('SALE_ID', id) | ||
33 | + .replace('ADDED_PRODUCTS', $.map($('.search-product-field'), function(item){return item.value}).join(',')); | ||
34 | + var prePopulation = []; | ||
35 | + var quantity = ''; | ||
36 | + var price = ''; | ||
37 | + var required = ''; | ||
38 | + if(item) { | ||
39 | + item.sale_id = id; | ||
40 | + prePopulation = [item]; | ||
41 | + quantity = item.quantity; | ||
42 | + price = item.product_price; | ||
43 | + required = 'required'; | ||
44 | + } | ||
45 | + var opts = $.extend( { prePopulate: prePopulation, queryParam: input[0].name }, this.tokenInputOptions ); | ||
46 | + | ||
47 | + input.keydown(function(event){ if(event.keyCode == '13') return false }) | ||
48 | + .tokenInput(searchUrl, opts); | ||
49 | + $('#bsc-plugin-contract-total-row').before(tr); | ||
50 | + $('<input id="bsc-plugin-sale-'+id+'-quantity" class="bsc-plugin-sales-quantity '+required+' digits" name="sales['+id+'][quantity]" align="center" size="7" value="'+quantity+'"/>').appendTo(tds[1]); | ||
51 | + $('<input id="bsc-plugin-sale-'+id+'-price" class="bsc-plugin-sales-price '+required+' number" name="sales['+id+'][price]" value="'+price+'"/>').appendTo(tds[2]); | ||
52 | + }; | ||
53 | + | ||
54 | + BSCContracts.prePopulate = function(items){ | ||
55 | + $(items).each(function(index, item){BSCContracts.newProductLine(item)}); | ||
56 | + } | ||
57 | + | ||
58 | + BSCContracts.updateTotal = function(){ | ||
59 | + var total = 0; | ||
60 | + var quantity = 0; | ||
61 | + var price = 0; | ||
62 | + $('.bsc-plugin-sales-product').each(function(index){ | ||
63 | + quantity = $('#' + $(this).attr('id') + " .bsc-plugin-sales-quantity").val(); | ||
64 | + price = $('#'+$(this).attr('id') + " .bsc-plugin-sales-price").val(); | ||
65 | + total += quantity*price; | ||
66 | + }); | ||
67 | + $('#bsc-plugin-sales-total-value').text(BSCContracts.currencyUnit+' '+total); | ||
68 | + } | ||
69 | + | ||
70 | + $(".bsc-plugin-sales-price, .bsc-plugin-sales-quantity").live('change', function(e){ | ||
71 | + BSCContracts.updateTotal(); | ||
72 | + }); | ||
73 | + | ||
74 | + $("#bsc-plugin-add-new-product").click(function(){ | ||
75 | + var last = $('.search-product-field:last'); | ||
76 | + if(!last.val() && last.size() != 0){ | ||
77 | + last.focus(); | ||
78 | + return false; | ||
79 | + } | ||
80 | + var next_id = parseInt(last.attr('data-sale-id'))+1; | ||
81 | + var enterprises = $('#involved-enterprises').val().replace(/,/g,'-'); | ||
82 | + BSCContracts.newProductLine(); | ||
83 | + return false; | ||
84 | + }); | ||
85 | + | ||
86 | +})(jQuery); |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +var dates = jQuery( "#from, #to" ).datepicker({ | ||
2 | + defaultDate: "+1w", | ||
3 | + changeMonth: true, | ||
4 | + dateFormat: 'yy-mm-dd', | ||
5 | + onSelect: function( selectedDate ) { | ||
6 | + var option = this.id == "from" ? "minDate" : "maxDate", | ||
7 | + instance = jQuery( this ).data( "datepicker" ), | ||
8 | + date = jQuery.datepicker.parseDate( | ||
9 | + instance.settings.dateFormat || | ||
10 | + jQuery.datepicker._defaults.dateFormat, | ||
11 | + selectedDate, instance.settings ); | ||
12 | + dates.not( this ).datepicker( "option", option, date ); | ||
13 | + } | ||
14 | +}); |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +Subproject commit bd879003043b4a93b78cbd4a582b6e0650900bcb |
plugins/bsc/public/style.css
1 | +@import url(jquery.ui.spinner/ui.spinner.css); | ||
2 | + | ||
1 | .controller-profile_editor a.control-panel-bsc-enterprises {background-image: url(images/manage-bsc-enterprises.png)} | 3 | .controller-profile_editor a.control-panel-bsc-enterprises {background-image: url(images/manage-bsc-enterprises.png)} |
2 | .controller-profile_editor .msie6 a.control-panel-bsc-enterprises {background-image: url(images/manage-bsc-enterprises.gif)} | 4 | .controller-profile_editor .msie6 a.control-panel-bsc-enterprises {background-image: url(images/manage-bsc-enterprises.gif)} |
3 | 5 | ||
4 | .controller-profile_editor a.control-panel-transfer-enterprise-ownership {background-image: url(images/transfer-ownership.png)} | 6 | .controller-profile_editor a.control-panel-transfer-enterprise-ownership {background-image: url(images/transfer-ownership.png)} |
5 | 7 | ||
8 | +.ui-spinner-up{ | ||
9 | + height: 6.5px !important; | ||
10 | +} | ||
11 | + | ||
12 | +.ui-spinner-down{ | ||
13 | + height: 8.5px !important; | ||
14 | +} | ||
15 | + | ||
16 | +.ui-icon-triangle-1-n { | ||
17 | + margin-top: -4px !important; | ||
18 | +} | ||
19 | + | ||
20 | +.ui-icon-triangle-1-s { | ||
21 | + margin-left: -1px !important; | ||
22 | + margin-top: -3.5px !important; | ||
23 | +} | ||
24 | + | ||
6 | .icon-menu-bsc { | 25 | .icon-menu-bsc { |
7 | background-image: url(images/manage-bsc-enterprises-icon.png); | 26 | background-image: url(images/manage-bsc-enterprises-icon.png); |
8 | } | 27 | } |
@@ -10,3 +29,154 @@ | @@ -10,3 +29,154 @@ | ||
10 | #content .token-input-list { | 29 | #content .token-input-list { |
11 | margin-bottom: 30px; | 30 | margin-bottom: 30px; |
12 | } | 31 | } |
32 | + | ||
33 | +#bsc-plugin-sorter { | ||
34 | + text-align: right; | ||
35 | + margin: 3px 0px; | ||
36 | +} | ||
37 | + | ||
38 | +#bsc-plugin-sales-table th, | ||
39 | +#bsc-plugin-sales-table td { | ||
40 | + border: 1px solid #000; | ||
41 | + border-collapse: collapse; | ||
42 | + padding: 0px | ||
43 | +} | ||
44 | + | ||
45 | +#content #bsc-plugin-sales-table td .token-input-list{ | ||
46 | + margin-bottom: 0px; | ||
47 | +} | ||
48 | + | ||
49 | +#bsc-plugin-sales-table { | ||
50 | + border: 1px solid #000; | ||
51 | + border-collapse: collapse; | ||
52 | +} | ||
53 | + | ||
54 | +#bsc-plugin-sales-table th { | ||
55 | + background-color: #cdcdcd; | ||
56 | + padding: 0px 10px; | ||
57 | +} | ||
58 | + | ||
59 | +.alternate-colors tr:nth-child(odd), | ||
60 | +.alternate-colors tr:nth-child(odd):hover td { | ||
61 | + background-color: #f4f4f4; | ||
62 | +} | ||
63 | + | ||
64 | +.alternate-colors tr:nth-child(even), | ||
65 | +.alternate-colors tr:nth-child(even):hover td { | ||
66 | + background-color: #fff; | ||
67 | +} | ||
68 | + | ||
69 | +#bsc-plugin-sales-table input.error{ | ||
70 | + background-color: #F8DBDD; | ||
71 | + border: 1px solid #f5697c; | ||
72 | + margin-left: 2px; | ||
73 | +} | ||
74 | + | ||
75 | +.bsc-plugin-sales-price { | ||
76 | + width: 85%; | ||
77 | +} | ||
78 | + | ||
79 | +.bsc-plugin-sales-products-column { | ||
80 | + width: 70%; | ||
81 | +} | ||
82 | + | ||
83 | +.bsc-plugin-sales-quantity-column { | ||
84 | + width: 10%; | ||
85 | + text-align: center; | ||
86 | +} | ||
87 | + | ||
88 | +.bsc-plugin-sales-price-column { | ||
89 | + width: 18%; | ||
90 | +} | ||
91 | + | ||
92 | +#bsc-plugin-sales-add-new-row { | ||
93 | + padding: 0px 10px; | ||
94 | +} | ||
95 | + | ||
96 | +#bsc-plugin-manage-contracts-table a { | ||
97 | + color: #555753; | ||
98 | +} | ||
99 | + | ||
100 | +#bsc-plugin-manage-contracts-table { | ||
101 | + border:none; | ||
102 | +} | ||
103 | +#bsc-plugin-manage-contracts-table td { | ||
104 | + padding: 5px 10px; | ||
105 | +} | ||
106 | + | ||
107 | +#bsc-plugin-manage-contracts-table td.links { | ||
108 | + text-align: right; | ||
109 | +} | ||
110 | + | ||
111 | +#bsc-plugin-contracts-filter { | ||
112 | + float: left; | ||
113 | + width: 20%; | ||
114 | + height: 100%; | ||
115 | +} | ||
116 | + | ||
117 | + | ||
118 | +#bsc-plugin-contracts-results { | ||
119 | + float: left; | ||
120 | + width: 80%; | ||
121 | +} | ||
122 | + | ||
123 | +#bsc-plugin-contract-total-string, | ||
124 | +#bsc-plugin-contract-total { | ||
125 | + text-align: right; | ||
126 | +} | ||
127 | + | ||
128 | +.bsc-fields-table { | ||
129 | + border: collapse; | ||
130 | + width: 49%; | ||
131 | +} | ||
132 | + | ||
133 | +.bsc-fields-table th{ | ||
134 | + font-size: 14px; | ||
135 | + padding: 0px; | ||
136 | +} | ||
137 | + | ||
138 | +.bsc-fields-table td { | ||
139 | + border: none; | ||
140 | + padding: 0px; | ||
141 | +} | ||
142 | + | ||
143 | +.bsc-fields-table tr:hover td { | ||
144 | + background-color: transparent; | ||
145 | +} | ||
146 | + | ||
147 | +.bsc-field-label { | ||
148 | + font-weight: bold; | ||
149 | +} | ||
150 | + | ||
151 | +.bsc-full-table { | ||
152 | + margin: 3px 0px; | ||
153 | +} | ||
154 | + | ||
155 | +.bsc-plugin-view-contract { | ||
156 | + margin-top: 10px; | ||
157 | +} | ||
158 | + | ||
159 | +.bsc-plugin-view-contract td { | ||
160 | + padding: 2px 10px !important; | ||
161 | +} | ||
162 | + | ||
163 | +.bsc-plugin-total { | ||
164 | + font-weight: bold; | ||
165 | +} | ||
166 | + | ||
167 | +.bsc-plugin-annotation { | ||
168 | + background-color: #eeeeec; | ||
169 | + margin: 10px 0px; | ||
170 | + padding: 5px 10px; | ||
171 | + border-radius: 5px; | ||
172 | +} | ||
173 | + | ||
174 | +.bsc-plugin-annotation-title { | ||
175 | + font-weight: bold; | ||
176 | + font-size: 15px; | ||
177 | + margin-bottom: 5px; | ||
178 | +} | ||
179 | + | ||
180 | +.bsc-plugin-annotation-content { | ||
181 | + font-style: italic; | ||
182 | +} |
plugins/bsc/views/bsc_plugin_environment/validate_enterprises.html.erb
1 | <h1><%= _('Validate enterprises') %></h1> | 1 | <h1><%= _('Validate enterprises') %></h1> |
2 | 2 | ||
3 | <% form_tag :action => 'save_validations' do %> | 3 | <% form_tag :action => 'save_validations' do %> |
4 | - <%= text_field_tag(:q, nil, :id => 'search-enterprises') %> | 4 | + <%= token_input_field_tag(:q, 'search-enterprises', {:action => 'search_enterprise'}, |
5 | + { :hint_text => _('Type in a search term for enterprise'), | ||
6 | + :focus => true }) %> | ||
5 | 7 | ||
6 | <% button_bar do %> | 8 | <% button_bar do %> |
7 | <%= submit_button('save', _('Save'))%> | 9 | <%= submit_button('save', _('Save'))%> |
8 | <%= button('cancel', _('Cancel'), {:controller => 'admin_panel'})%> | 10 | <%= button('cancel', _('Cancel'), {:controller => 'admin_panel'})%> |
9 | <% end %> | 11 | <% end %> |
10 | <% end %> | 12 | <% end %> |
11 | - | ||
12 | -<%= javascript_include_tag '/plugins/bsc/jquery_tokeninput/src/jquery.tokeninput.js' %> | ||
13 | -<% stylesheet('/plugins/bsc/jquery_tokeninput/styles/token-input.css') %> | ||
14 | -<% search_url = url_for(:action => 'search_enterprise') %> | ||
15 | -<script type="text/javascript"> | ||
16 | - jQuery("#search-enterprises") | ||
17 | - .tokenInput("<%= search_url %>", { | ||
18 | - hintText: <%= _('Type in a search term for enterprise').to_json %>, | ||
19 | - noResultsText: <%= _('No results').to_json %>, | ||
20 | - searchingText: <%= _('Searching...').to_json %>, | ||
21 | - searchDelay: 500, | ||
22 | - backspaceDeleteItem: false | ||
23 | - }) | ||
24 | - .focus(); | ||
25 | - | ||
26 | - jQuery("#token-input-search-enterprises") | ||
27 | - .live("keydown", function(event){ | ||
28 | - if(event.keyCode == "13") return false; | ||
29 | - }); | ||
30 | -</script> | ||
31 | - |
plugins/bsc/views/bsc_plugin_myprofile/_contract_form.html.erb
0 → 100644
@@ -0,0 +1,83 @@ | @@ -0,0 +1,83 @@ | ||
1 | +<%= error_messages_for :contract %> | ||
2 | + | ||
3 | +<% labelled_form_for :contract, @contract, :html => {:id => 'bsc-plugin-sales-form'} do |f| %> | ||
4 | + <%= hidden_field_tag :contract_id, @contract.id %> | ||
5 | + <%= required f.text_field(:client_name) %> | ||
6 | + <%= labelled_form_field(_('Client type'), f.select(:client_type, BscPlugin::Contract::ClientType.types.map{|type| [BscPlugin::Contract::ClientType.names[type], type]}))%> | ||
7 | + <%= labelled_form_field(_('Business type'), f.select(:business_type, BscPlugin::Contract::BusinessType.types.map{|type| [BscPlugin::Contract::BusinessType.names[type], type]}))%> | ||
8 | + <%= f.text_field(:state) %> | ||
9 | + <%= f.text_field(:city) %> | ||
10 | + <%= labelled_form_field(_('Status'), f.select(:status, BscPlugin::Contract::Status.types. | ||
11 | + map { |s| [BscPlugin::Contract::Status.names[s], s] })) %> | ||
12 | + <%= f.text_field(:number_of_producers, :size => 8, :id => 'bsc-plugin-contract-spinner') %> | ||
13 | + <%= _('Empreendimentos')+':' %> | ||
14 | + | ||
15 | + <% search_action = {:action => 'search_contract_enterprises', :profile => profile.identifier} %> | ||
16 | + <%= token_input_field_tag(:enterprises, 'involved-enterprises', search_action, | ||
17 | + { :pre_populate => @contract.enterprises_to_token_input, | ||
18 | + :hint_text => _('Type in serach term for enterprise') }) %> | ||
19 | + | ||
20 | + <table id="bsc-plugin-sales-table" class="alternate-colors"> | ||
21 | + <tr> | ||
22 | + <th class="bsc-plugin-sales-products-column"><%= _('Products') %></th> | ||
23 | + <th class="bsc-plugin-sales-quantity-column" ><%= _('Quantity') %></th> | ||
24 | + <th class="bsc-plugin-sales-price-column" ><%= _('Unit price') %></th> | ||
25 | + </tr> | ||
26 | + <tr id='bsc-plugin-contract-total-row'> | ||
27 | + <td id="bsc-plugin-contract-total-string" colspan="2" ><strong><%= _('Total')%></strong></td> | ||
28 | + <td id="bsc-plugin-contract-total"><strong id='bsc-plugin-sales-total-value'><%= float_to_currency(@contract.total_price)%></strong></td> | ||
29 | + </tr> | ||
30 | + <tr> | ||
31 | + <td colspan="3" class="bsc-plugin-sales-add-new-row"><%= link_to(_('Add new product'), {}, :id => 'bsc-plugin-add-new-product', 'data-bsc' => profile.identifier) %></td> | ||
32 | + </tr> | ||
33 | + </table> | ||
34 | + | ||
35 | + <%= labelled_form_field( _('Supply period'), | ||
36 | + text_field_tag('contract[supply_start]', (@contract.supply_start ? @contract.supply_start.strftime("%Y-%m-%d") : nil), :id => 'from', :size => 9) + | ||
37 | + _(' to ') + | ||
38 | + text_field_tag('contract[supply_end]', (@contract.supply_end ? @contract.supply_end.strftime("%Y-%m-%d") : nil), :id => 'to', :size => 9) ) | ||
39 | + %> | ||
40 | + | ||
41 | + <%= f.text_area(:annotations, :rows => 5, :cols => 68) %> | ||
42 | + <% button_bar do%> | ||
43 | + <%= submit_button(:save, _('Save'), :cancel => {:action => 'manage_contracts'})%> | ||
44 | + <% end %> | ||
45 | +<% end %> | ||
46 | + | ||
47 | +<% scripts = %w{/plugins/bsc/jquery.ui.spinner/ui.spinner.js | ||
48 | + /plugins/bsc/contracts /plugins/bsc/datepicker | ||
49 | + /plugins/bsc/spinner} %> | ||
50 | +<% scripts.each do |script|%> | ||
51 | + <%= javascript_include_tag script %> | ||
52 | +<% end %> | ||
53 | + | ||
54 | +<script> | ||
55 | + BSCContracts.tokenInputOptions = { | ||
56 | + minChars: 3, | ||
57 | + hintText: <%= _('Type in a search term for product').to_json %>, | ||
58 | + noResultsText: <%= _("No results").to_json %>, | ||
59 | + searchingText: <%= _("Searching...").to_json %>, | ||
60 | + searchDelay: 1000, | ||
61 | + preventDuplicates: true, | ||
62 | + backspaceDeleteItem: false, | ||
63 | + tokenLimit: 1, | ||
64 | + onDelete: BSCContracts.onDelete, | ||
65 | + onAdd: BSCContracts.onAdd | ||
66 | + }; | ||
67 | + BSCContracts.searchUrl = <%= url_for( | ||
68 | + :action => 'search_sale_product', | ||
69 | + :profile => profile.identifier, | ||
70 | + :enterprises => 'ENTERPRISES', | ||
71 | + :sale_id => 'SALE_ID', | ||
72 | + :added_products => 'ADDED_PRODUCTS', | ||
73 | + :escape => true).to_json %>.replace(/amp;/g,""); | ||
74 | + BSCContracts.currencyUnit = <%= profile.environment.currency_unit.to_json %>; | ||
75 | + BSCContracts.prePopulate( <%= @contract.sales.map{|sale| { | ||
76 | + :id => sale.product_id, | ||
77 | + :name => short_text(product_display_name(sale.product), 60), | ||
78 | + :product_price => sale.price || sale.product.price || 0, | ||
79 | + :quantity => sale.quantity}}.to_json | ||
80 | + %>); | ||
81 | +</script> | ||
82 | + | ||
83 | +<%= javascript_include_tag '/plugins/bsc/validation' %> |
plugins/bsc/views/bsc_plugin_myprofile/edit_contract.html.erb
0 → 100644
plugins/bsc/views/bsc_plugin_myprofile/manage_associated_enterprises.html.erb
@@ -10,7 +10,11 @@ | @@ -10,7 +10,11 @@ | ||
10 | <% end %> | 10 | <% end %> |
11 | 11 | ||
12 | <% form_tag :action => 'save_associations' do %> | 12 | <% form_tag :action => 'save_associations' do %> |
13 | - <%= text_field_tag(:q, nil, :id => 'search-enterprises') %> | 13 | + <% search_action = {:action => 'search_enterprise', :profile => profile.identifier} %> |
14 | + <%= token_input_field_tag(:q, 'search-enterprises', search_action, | ||
15 | + { :pre_populate => profile.enterprises_to_token_input, | ||
16 | + :hint_text => _('Type in a search term for enterprise'), | ||
17 | + :focus => true }) %> | ||
14 | 18 | ||
15 | <%= button('add', _('Add new enterprise'), {:action => 'create_enterprise'}) %> | 19 | <%= button('add', _('Add new enterprise'), {:action => 'create_enterprise'}) %> |
16 | 20 | ||
@@ -20,24 +24,3 @@ | @@ -20,24 +24,3 @@ | ||
20 | <% end %> | 24 | <% end %> |
21 | 25 | ||
22 | <% end %> | 26 | <% end %> |
23 | -<%= javascript_include_tag '/plugins/bsc/jquery_tokeninput/src/jquery.tokeninput.js' %> | ||
24 | -<% stylesheet('/plugins/bsc/jquery_tokeninput/styles/token-input.css') %> | ||
25 | -<% search_url = url_for(:action => 'search_enterprise', :profile => profile.identifier) %> | ||
26 | -<script type="text/javascript"> | ||
27 | - jQuery("#search-enterprises") | ||
28 | - .tokenInput("<%= search_url %>", { | ||
29 | - minChars: 3, | ||
30 | - prePopulate: <%= profile.enterprises_to_json %>, | ||
31 | - hintText: <%= _('Type in a search term for enterprise').to_json %>, | ||
32 | - noResultsText: <%= _('No results').to_json %>, | ||
33 | - searchingText: <%= _('Searching...').to_json %>, | ||
34 | - searchDelay: 500, | ||
35 | - backspaceDeleteItem: false | ||
36 | - }) | ||
37 | - .focus(); | ||
38 | - | ||
39 | - jQuery("#token-input-search-enterprises") | ||
40 | - .live("keydown", function(event){ | ||
41 | - if(event.keyCode == "13") return false; | ||
42 | - }); | ||
43 | -</script> |
plugins/bsc/views/bsc_plugin_myprofile/manage_contracts.html.erb
0 → 100644
@@ -0,0 +1,49 @@ | @@ -0,0 +1,49 @@ | ||
1 | +<h1><%= _('Manage contracts') %></h1> | ||
2 | + | ||
3 | +<% form_tag({}, {:id => "bsc-plugin-contracts-form"}) do %> | ||
4 | + <div id="bsc-plugin-contracts-filter"> | ||
5 | + <h2><%= _('Status') %></h2> | ||
6 | + <% BscPlugin::Contract::Status.types.each do |status| %> | ||
7 | + <%= check_box_tag('status[]', status, @status.include?(status.to_s), :id => 'status-checkbox-'+status.to_s) %> | ||
8 | + <%= content_tag('label', BscPlugin::Contract::Status.names[status], :for => 'status-checkbox-'+status.to_s) %> | ||
9 | + <br style="clear:both" /> | ||
10 | + <% end %> | ||
11 | + <br style="clear:both" /> | ||
12 | + <%= submit_button(:save, _('Filter')) %> | ||
13 | + </div> | ||
14 | + | ||
15 | + <div id='bsc-plugin-contracts-results'> | ||
16 | + <div id="bsc-plugin-sorter"> | ||
17 | + <%= labelled_select(_('Sort by')+' ', :sorting, :first, :last, @sorting, | ||
18 | + [['created_at asc', _('Date(newest first)')], ['created_at desc', _('Date(oldest first)')], | ||
19 | + ['client_name asc', _('Client name(A-Z)')], ['client_name desc', _('Client name(Z-A)')]], | ||
20 | + :onchange => "jQuery('#bsc-plugin-contracts-form').submit()") %> | ||
21 | + </div> | ||
22 | + | ||
23 | + <% if @contracts.blank? %> | ||
24 | + <%= content_tag('em', _('There are no contracts at all.'))%> | ||
25 | + <% else %> | ||
26 | + <table id="bsc-plugin-manage-contracts-table" class="alternate-colors"> | ||
27 | + <% @contracts.each do |contract| %> | ||
28 | + <tr> | ||
29 | + <td> | ||
30 | + <%= link_to(content_tag('b', contract.client_name ), :action => 'view_contract', :contract_id => contract.id) %> <br /> | ||
31 | + <%= content_tag('i', show_date(contract.created_at)) %> | ||
32 | + </td> | ||
33 | + <td class="links"> | ||
34 | + <%= link_to(_('Edit'), :action => 'edit_contract', :contract_id => contract.id)%> | ||
35 | + <%= link_to(_('Remove'), {:action => 'destroy_contract', :contract_id => contract.id}, :confirm => _('Are you sure?'))%> | ||
36 | + </td> | ||
37 | + </tr> | ||
38 | + <% end %> | ||
39 | + </table> | ||
40 | + <%= pagination_links @contracts %> | ||
41 | + <% end %> | ||
42 | + | ||
43 | + <% button_bar do %> | ||
44 | + <%= button(:back, _('Go back'), :controller => 'profile_editor') %> | ||
45 | + <%= button(:new, _('Create new contract'), :action => 'new_contract')%> | ||
46 | + <% end %> | ||
47 | + </div> | ||
48 | +<% end %> | ||
49 | +<br style="clear:both" /> |
plugins/bsc/views/bsc_plugin_myprofile/new_contract.html.erb
0 → 100644
plugins/bsc/views/bsc_plugin_myprofile/transfer_ownership.html.erb
@@ -13,10 +13,16 @@ | @@ -13,10 +13,16 @@ | ||
13 | </ul> | 13 | </ul> |
14 | <% end %> | 14 | <% end %> |
15 | 15 | ||
16 | + | ||
16 | <% form_tag do %> | 17 | <% form_tag do %> |
17 | <% @roles.each do |role|%> | 18 | <% @roles.each do |role|%> |
18 | <%= content_tag('b', _('Administrator:')) %> | 19 | <%= content_tag('b', _('Administrator:')) %> |
19 | - <%= text_field_tag('q_'+role.key, nil, :id => 'search_'+role.key) %> | 20 | + <% search_action = {:controller => 'profile_members', :action => 'search_user', :role => role.id, :profile => profile.identifier} %> |
21 | + <%= token_input_field_tag('q_'+role.key, 'search_'+role.key, search_action, | ||
22 | + { :hint_text => _('Type in a search term for the new administrator'), | ||
23 | + :focus => true, | ||
24 | + :token_limit => 1}) %> | ||
25 | + | ||
20 | <% end %> | 26 | <% end %> |
21 | 27 | ||
22 | <% button_bar do %> | 28 | <% button_bar do %> |
@@ -24,31 +30,3 @@ | @@ -24,31 +30,3 @@ | ||
24 | <%= button('cancel', _('Cancel'), {:controller => 'profile_editor'})%> | 30 | <%= button('cancel', _('Cancel'), {:controller => 'profile_editor'})%> |
25 | <% end %> | 31 | <% end %> |
26 | <% end %> | 32 | <% end %> |
27 | - | ||
28 | -<%= javascript_include_tag '/plugins/bsc/jquery_tokeninput/src/jquery.tokeninput.js' %> | ||
29 | -<% stylesheet('/plugins/bsc/jquery_tokeninput/styles/token-input.css') %> | ||
30 | - | ||
31 | -<% @roles.each do |role| %> | ||
32 | - <% search_url = url_for(:controller => 'profile_members', :action => 'search_user', :role => role.id, :profile => profile.identifier) %> | ||
33 | - <script type="text/javascript"> | ||
34 | - jQuery(<%= ('#search_' + role.key).to_json %>) | ||
35 | - .tokenInput("<%= search_url %>", { | ||
36 | - hintText: <%= _('Type in a search term for the new administrator').to_json %>, | ||
37 | - noResultsText: <%= _('No results').to_json %>, | ||
38 | - searchingText: <%= _('Searching...').to_json %>, | ||
39 | - searchDelay: 500, | ||
40 | - backspaceDeleteItem: false, | ||
41 | - preventDuplicates: true, | ||
42 | - tokenLimit: 1, | ||
43 | - queryParam: <%= ('q_'+role.key).to_json %> | ||
44 | - }) | ||
45 | - .focus(); | ||
46 | - | ||
47 | - jQuery("#token-input-search-enterprises") | ||
48 | - .live("keydown", function(event){ | ||
49 | - if(event.keyCode == "13") return false; | ||
50 | - }); | ||
51 | - </script> | ||
52 | -<% end %> | ||
53 | - | ||
54 | - |
plugins/bsc/views/bsc_plugin_myprofile/view_contract.html.erb
0 → 100644
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<h1><%= @contract.client_name %></h1> | ||
2 | + | ||
3 | +<table class='bsc-fields-table' style="float: left;"> | ||
4 | + <tr> | ||
5 | + <th colspan='2'><%= _('Basic information') %></th> | ||
6 | + </tr> | ||
7 | + <%= display_text_field(_('Client type'), BscPlugin::Contract::ClientType.names[@contract.client_type]) %> | ||
8 | + <%= display_text_field(_('Business type'), BscPlugin::Contract::BusinessType.names[@contract.business_type]) %> | ||
9 | + <%= display_text_field(_('State'), @contract.state) %> | ||
10 | + <%= display_text_field(_('City'), @contract.city) %> | ||
11 | + <%= display_text_field(_('Status'), BscPlugin::Contract::Status.names[@contract.status]) %> | ||
12 | + <%= display_text_field(_('Number of producers'), @contract.number_of_producers) %> | ||
13 | + <%= display_text_field(_('Supply period'), show_period(@contract.supply_start, @contract.supply_end, true)) %> | ||
14 | +</table> | ||
15 | + | ||
16 | +<table class='bsc-fields-table' style="float: right;"> | ||
17 | + <tr> | ||
18 | + <th colspan='2'><%= _('Enterprises') %></th> | ||
19 | + </tr> | ||
20 | + <%= display_list_field(@contract.enterprises.map {|enterprise| link_to(enterprise.short_name(60), enterprise.url)}) %> | ||
21 | +</table> | ||
22 | + | ||
23 | +<% if !@contract.sales.blank?%> | ||
24 | + <table id='bsc-plugin-sales-table' class="bsc-plugin-view-contract alternate-colors"> | ||
25 | + <tr> | ||
26 | + <th><%= _('Product') %></th> | ||
27 | + <th align="center"><%= _('Quantity') %></th> | ||
28 | + <th><%= _('Unit price') %></th> | ||
29 | + </tr> | ||
30 | + <% @contract.sales.each do |sale| %> | ||
31 | + <tr> | ||
32 | + <td><%= short_text(product_display_name(Product.find(sale.product_id)), 110) %></td> | ||
33 | + <td align="center"><%= sale.quantity %></td> | ||
34 | + <td align="right"><%= float_to_currency(sale.price) %></td> | ||
35 | + </tr> | ||
36 | + <% end %> | ||
37 | + <tr> | ||
38 | + <td id="bsc-plugin-contract-total-string" class="bsc-plugin-total" colspan='2'><%= _('Total')%></td> | ||
39 | + <td id="bsc-plugin-contract-total" class="bsc-plugin-total"><%= float_to_currency(@contract.total_price) %></td> | ||
40 | + </tr> | ||
41 | + </table> | ||
42 | +<% end %> | ||
43 | + | ||
44 | +<br style="clear: both" /> | ||
45 | + | ||
46 | +<% if !@contract.annotations.blank? %> | ||
47 | + <div class="bsc-plugin-annotation"> | ||
48 | + <div class="bsc-plugin-annotation-title"><%= _("Annotations") %></div> | ||
49 | + <div class="bsc-plugin-annotation-content"><%= @contract.annotations %></div> | ||
50 | + </div> | ||
51 | +<% end %> | ||
52 | + | ||
53 | +<% button_bar do %> | ||
54 | + <%= button(:back, _('Go back'), :action => 'manage_contracts') %> | ||
55 | +<% end %> |