]> git.agnieray.net Git - galette.git/blob - galette/templates/default/pages/contribution_form.html.twig
8e0ad920a61a012c98dd1b191bc88a216bf736a4
[galette.git] / galette / templates / default / pages / contribution_form.html.twig
1 {% extends (mode == 'ajax') ? "ajax.html.twig" : "page.html.twig" %}
2
3 {% block content %}
4 {% if members.list is defined or require_mass %}
5 {% if mode != 'ajax' %}
6 <form action="{% if contribution.id %}{{ url_for("doEditContribution", {"type": type, "id": contribution.id}) }}{% else %}{{ url_for("doAddContribution", {"type": type}) }}{% endif %}" enctype="multipart/form-data" method="post" class="ui form">
7 {% endif %}
8 <div class="ui styled fluid accordion field">
9 <div class="active title">
10 <i class="jsonly displaynone icon dropdown" aria-hidden="true"></i>
11 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}
12 {{ _T("Select contributor and membership fee type") }}
13 {% else %}
14 {{ _T("Select contributor and donation type") }}
15 {% endif %}
16 {% if contribution.isTransactionPart() %}
17 <span class="ui teal horizontal label">
18 {{ _T("Transaction related") }}
19 </span>
20 {% endif %}
21 </div>
22 <div class="active content">
23 <div class="ui mobile reversed stackable grid">
24 <div class="{% if contribution.isTransactionPart() %}five wide {% endif %}column">
25 {% if not require_mass %}
26 <div class="inline field">
27 <label for="id_adh">{{ _T("Contributor:") }}</label>
28 <div id="id_adh" class="jsonly search-dropdown ui input nochosen paginated">
29 <input id="id_adh_input" type="hidden" name="id_adh" value="{{ contribution.member is not null ? contribution.member }}" placeholder="{{ _T("Member ID") }}">
30 <i class="jsonly displaynone dropdown icon" aria-hidden="true"></i>
31 <span class="ui mini compact icon disabled button prev-results"><i class="jsonly displaynone chevron circle left icon disabled button tooltip" title="{{ _T("Load previous members...") }}" aria-hidden="true"></i></span>
32 <span class="ui mini compact icon disabled button next-results"><i class="jsonly displaynone chevron circle right icon disabled button tooltip" title="{{ _T("Load following members...") }}" aria-hidden="true"></i></span>
33 <div class="jsonly displaynone default text">{% if adh_selected == 0 %}{{ _T("Search for name or ID and pick member") }}{% endif %}</div>
34 <div class="jsonly displaynone menu">
35 {% for k, v in members.list %}
36 <div class="item" data-value="{{ k }}">{{ v }}</div>
37 {% endfor %}
38 </div>
39 </div>
40 </div>
41 {% endif %}
42 <div class="inline field{% if required.id_type_cotis is defined and required.id_type_cotis == 1 %} required{% endif %}">
43 <label for="id_type_cotis">{{ _T("Contribution type:") }}</label>
44 <div id="id_type_cotis" class="ui dropdown selection nochosen">
45 {% if contribution.type %}
46 {% set selectedid = contribution.type.id %}
47 {% else %}
48 {% set selectedid = null %}
49 {% endif %}
50 <input id="id_type_cotis_input" type="hidden" name="id_type_cotis" value="{{ selectedid }}"{% if required.id_type_cotis is defined and required.id_type_cotis == 1 %} required="required"{% endif %}>
51 <i class="dropdown icon"></i>
52 <div class="text">{% for key, value in type_cotis_options %}{% if key == selectedid %}{{ value }}{% endif %}{% endfor %}</div>
53 <div class="menu">
54 {% for key, value in type_cotis_options %}
55 <div class="item{% if key == selectedid %} active selected{% endif %}" data-value="{{ key }}">{{ value }}</div>
56 {% endfor %}
57 </div>
58 </div>
59 </div>
60 {% if contribution.isTransactionPart() and contribution.transaction.getMissingAmount() %}
61 <div class="inline field">
62 <label>{{ _T("Dispatch type:") }}</label>
63 <i class="circular inverted primary small icon info tooltip" title="{{ _T("Select a contribution type to create for dispatch transaction") }}" aria-hidden="true"></i>
64 <input type="radio" name="contrib_type" id="contrib_type_fee" value="{{ constant('Galette\\Entity\\Contribution::TYPE_FEE') }}" checked="checked"/> <label for="contrib_type_fee">{{ _T("Membership fee") }}</label>
65 <input type="radio" name="contrib_type" id="contrib_type_donation" value="donation"/> <label for="contrib_type_donation">{{ _T("Donation") }}</label>
66 </div>
67 {% endif %}
68 </div>
69 {% if contribution.isTransactionPart() %}
70 <div class="eleven wide column">
71 {% set mid = contribution.transaction.member %}
72 <div class="ui tiny header">{{ _T("Related transaction information") }}</div>
73 <table id="transaction_detail" class="listing ui very compact yellow table">
74 <thead>
75 <tr>
76 <th class="listing">#</th>
77 <th class="listing">{{ _T("Description") }}</th>
78 <th class="listing">{{ _T("Date") }}</th>
79 <th class="listing">{{ _T("Member") }}</th>
80 <th class="listing">{{ _T("Amount") }}</th>
81 <th class="listing">{{ _T("Not dispatched amount") }}</th>
82 </tr>
83 </thead>
84 {% if contribution.id and contribution.isTransactionPart() %}
85 <tfoot>
86 <tr>
87 <td colspan="6">
88 <div class="ui basic fitted right aligned segment">
89 <a
90 href="{{ url_for("editTransaction", {"id": contribution.transaction.id}) }}"
91 class="ui icon blue compact button tooltip"
92 >
93 <i class="eye icon tooltip" aria-hidden="true"></i>
94 <span class="ui special popup">{{ _T("View transaction") }}</span>
95 </a>
96 {% if contribution.transaction.getMissingAmount() > 0 %}
97 <a
98 href="{{ url_for("addContribution", {"type": constant('Galette\\Entity\\Contribution::TYPE_FEE')}) }}?trans_id={{ contribution.transaction.id }}"
99 class="ui icon green compact button tooltip"
100 title="{{ _T("Create a new fee that will be attached to the current transaction") }}"
101 >
102 <i class="plus tiny icon" aria-hidden="true"></i>
103 <i class="user check icon" aria-hidden="true"></i>
104 <span class="visually-hidden">{{ _T("Create a new fee that will be attached to the current transaction") }}</span>
105 </a>
106 <a
107 href="{{ url_for("addContribution", {"type": constant('Galette\\Entity\\Contribution::TYPE_DONATION')}) }}?trans_id={{ contribution.transaction.id }}"
108 class="ui icon green compact button tooltip"
109 title="{{ _T("Create a new donation that will be attached to the current transaction") }}"
110 >
111 <i class="plus tiny icon" aria-hidden="true"></i>
112 <i class="gift icon" aria-hidden="true"></i>
113 <span class="visually-hidden">{{ _T("Create a new donation that will be attached to the current transaction") }}</span>
114 </a>
115 {% endif %}
116 </div>
117
118 </td>
119 </tr>
120 </tfoot>
121 {% endif %}
122 <tbody>
123 <tr>
124 <td>{{ contribution.transaction.id }}</td>
125 <td>{{ contribution.transaction.description }}</td>
126 <td>{{ contribution.transaction.date }}</td>
127 <td>{{ memberName({'id': mid}) }}</td>
128 <td class="right">{{ contribution.transaction.amount }}</td>
129 <td class="right">{{ contribution.transaction.getMissingAmount() }}</td>
130 </tr>
131 </tbody>
132 </table>
133 </div>
134 {% endif %}
135 </div>
136 </div>
137 </div>
138
139 <div class="ui styled fluid accordion field">
140 <div class="active title">
141 <i class="jsonly displaynone icon dropdown" aria-hidden="true"></i>
142 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}
143 {{ _T("Details of membership fee") }}
144 {% else %}
145 {{ _T("Details of donation") }}
146 {% endif %}
147 </div>
148 <div class="active content field">
149 <div id="contribdetails" class="ui basic fitted segment">
150 <div class="two fields">
151 <div class="field{% if required.montant_cotis is defined and required.montant_cotis == 1 %} required{% endif %}">
152 <label for="montant_cotis">{{ _T("Amount:") }}</label>
153 <input type="text" name="montant_cotis" id="montant_cotis" value="{{ contribution.amount }}" maxlength="10"{% if required.montant_cotis is defined and required.montant_cotis == 1 %} required="required"{% endif %}/>
154 </div>
155 {# payment type #}
156 {% set ptype = contribution.payment_type %}
157 {% if ptype == null %}
158 {% set ptype = constant('Galette\\Entity\\PaymentType::CHECK') %}
159 {% endif %}
160 {% include 'components/forms/payment_types.html.twig' with {'current': ptype, 'varname': 'type_paiement_cotis', 'show_inline': true} %}
161 </div>
162 <div class="{% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}three{% else %}two{% endif %} fields">
163 <div class="field{% if required.date_enreg is defined and required.date_enreg == 1 %} required{% endif %}">
164 <label for="date_enreg">
165 {{ _T("Record date:") }}
166 </label>
167 <div class="ui calendar" id="contribution-rangestart">
168 <div class="ui input left icon">
169 <i class="calendar icon" aria-hidden="true"></i>
170 <input type="text" name="date_enreg" id="date_enreg" value="{{ contribution.date }}" maxlength="10"{% if required.date_enreg is defined and required.date_enreg == 1 %} required="required"{% endif %}>
171 </div>
172 </div>
173 <span class="exemple">{{ _T("(yyyy-mm-dd format)") }}</span>
174 </div>
175 <div class="field{% if required.date_debut_cotis is defined and required.date_debut_cotis == 1 %} required{% endif %}">
176 <label for="date_debut_cotis">
177 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}
178 {{ _T("Start date of membership:") }}
179 {% else %}
180 {{ _T("Date of contribution:") }}
181 {% endif %}
182 </label>
183 <div class="ui calendar" id="contribution-rangeend">
184 <div class="ui input left icon">
185 <i class="calendar icon" aria-hidden="true"></i>
186 <input type="text" name="date_debut_cotis" id="date_debut_cotis" value="{{ contribution.begin_date }}" maxlength="10"{% if required.date_debut_cotis == 1 %} required="required"{% endif %}/>
187 </div>
188 </div>
189 <span class="exemple">{{ _T("(yyyy-mm-dd format)") }}</span>
190 </div>
191 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}
192 <div class="field{% if required.date_fin_cotis is defined and required.date_fin_cotis == 1 %} required{% endif %}">
193 {% if preferences.pref_membership_ext != "" %}
194 <label for="duree_mois_cotis">{{ _T("Membership extension:") }}</label>
195 <input type="text" name="duree_mois_cotis" id="duree_mois_cotis" value="{{ contribution.duration }}" maxlength="3"{% if required.date_fin_cotis is defined and required.date_fin_cotis == 1 %} required="required"{% endif %}/>
196 <span class="exemple">{{ _T("months") }}</span>
197 {% else %}
198 <label for="date_fin_cotis">{{ _T("End date of membership:") }}</label>
199 <div class="ui calendar" id="membership-rangeend">
200 <div class="ui input left icon">
201 <i class="calendar icon" aria-hidden="true"></i>
202 <input type="text" name="date_fin_cotis" id="date_fin_cotis" value="{{ contribution.end_date }}" maxlength="10"{% if required.date_fin_cotis is defined and required.date_fin_cotis == 1 %} required="required"{% endif %}/>
203 </div>
204 </div>
205 <span class="exemple">{{ _T("(yyyy-mm-dd format)") }}</span>
206 {% endif %}
207 </div>
208 {% endif %}
209 </div>
210 <div class="field{% if required.info_cotis is defined and required.info_cotis == 1 %} required{% endif %}">
211 <label for="info_cotis">{{ _T("Comments:") }}</label>
212 <textarea name="info_cotis" id="info_cotis" cols="61" rows="6"{% if required.info_cotis is defined and required.info_cotis == 1 %} required="required"{% endif %}>{{ contribution.info }}</textarea>
213 </div>
214 </div>
215 </div>
216 </div>
217
218 {% include 'components/dynamic_fields.html.twig' with {'object': contribution} %}
219
220 {% if not contribution.id and preferences.pref_mail_method != constant('Galette\\Core\\GaletteMail::METHOD_DISABLED') %}
221 {% if not require_mass %}
222 <div class="ui center aligned yellow segment">
223 <div class="inline field">
224 <div class="ui toggle checkbox">
225 <input type="checkbox" name="mail_confirm" id="mail_confirm" value="1"{% if preferences.pref_bool_mailowner or contribution.sendEMail() %} checked="checked"{% endif %}/>
226 <label for="mail_confirm">
227 {{ _T("Notify member") }}
228 </label>
229 <br/>
230 <span class="exemple">
231 {{ _T("Member will receive a notification by email, if he has an address.") }}
232 </span>
233 </div>
234 </div>
235 </div>
236 {% endif %}
237 {% endif %}
238 {% if not require_mass %}
239 <div class="ui basic center aligned segment">
240 <button type="submit" name="valid" class="ui labeled icon primary button action">
241 <i class="save icon" aria-hidden="true"></i> {{ _T("Save") }}
242 </button>
243 <input type="hidden" name="id_cotis" value="{{ contribution.id }}"/>
244 <input type="hidden" name="valid" value="1"/>
245 <input type="hidden" name="trans_id" value="{% if contribution.transaction != NULL %}{{ contribution.transaction.id }}{% endif %}"/>
246 </div>
247 {% endif %}
248 {% if mode != 'ajax' %}
249 {% include "components/forms/csrf.html.twig" %}
250 </form>
251 {% endif %}
252 {% elseif mode != 'ajax' %} {# No members #}
253 <div class="ui warning message" id="warningbox">
254 <h3>{{ _T("No member registered!") }}</h3>
255 <p>
256 {{ _T("Unfortunately, there is no member in your database yet,") }}
257 <br/>
258 <a href="{{ url_for("addMember") }}">{{ _T("please create a member") }}</a>
259 </p>
260 </div>
261 {% endif %}
262 {% endblock %}
263
264 {% block javascripts %}
265 <script type="text/javascript">
266 {% include "elements/js/choose_adh.js.twig" %}
267
268 $(function() {
269
270 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') and not contribution.id %}
271 $('#id_adh, #id_type_cotis').dropdown({
272 action: function(text, value, element) {
273 var element = element.parentElement !== undefined ? element : element[0];
274 var dropdown = element.parentElement.parentElement;
275 $(dropdown).find('div.text').html(text);
276 $(dropdown).dropdown('set selected', value);
277 $(dropdown).dropdown('hide');
278
279 var _member = $('#id_adh_input').val();
280 var _fee = $('#id_type_cotis_input').val();
281
282 $.ajax({
283 type: 'POST',
284 dataType: 'json',
285 url : '{{ url_for("contributionDates") }}',
286 data: {
287 member_id: _member,
288 fee_id: _fee
289 },
290 {% include "elements/js/loader.js.twig" with {
291 selector: '#contribdetails'
292 } %},
293 success: function(res){
294 $('#date_debut_cotis').val(res.date_debut_cotis);
295 $('#date_fin_cotis').val(res.date_fin_cotis);
296 },
297 error: function() {
298 {% include "elements/js/modal.js.twig" with {
299 modal_title_twig: _T("An error occurred retrieving dates :(")|e("js"),
300 modal_without_content: true,
301 modal_class: "mini",
302 modal_deny_only: true,
303 modal_cancel_text: _T("Close")|e("js"),
304 modal_classname: "redalert",
305 } %}
306 }
307 });
308
309 }
310 });
311 {% endif %}
312
313 {% if contribution.isTransactionPart() and contribution.transaction.getMissingAmount() %}
314 $('#transaction_related').hide();
315 $('#montant_cotis').on('keyup', function() {
316 var _amount = {{ contribution.transaction.getMissingAmount() }};
317 var _current = $(this).val();
318 if (_current < _amount) {
319 $('#transaction_related').show();
320 } else if (_current > _amount) {
321 {% include "elements/js/modal.js.twig" with {
322 modal_title_twig: _T("Contribution amount should not be greater than %max")|replace({'%max': contribution.transaction.getMissingAmount()})|e("js"),
323 modal_without_content: true,
324 modal_class: "mini",
325 modal_deny_only: true,
326 modal_cancel_text: _T("Close")|e("js"),
327 modal_classname: "redalert",
328 } %}
329 } else {
330 $('#transaction_related').hide();
331 }
332 });
333 {% endif %}
334 });
335 </script>
336 {% endblock %}