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