]> git.agnieray.net Git - galette.git/blob - galette/templates/default/pages/contribution_form.html.twig
2716982384a9da0d7724bac08564ca8fc7dbeda5
[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"></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="text" name="id_adh" value="{{ contribution.member is not null ? contribution.member }}" placeholder="{{ _T("Member ID") }}">
30 <i class="jsonly displaynone dropdown icon"></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...") }}"></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...") }}"></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">
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 == 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") }}"></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 small single line 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 <th class="listing">{{ _T("Actions") }}</th>
85 </tr>
86 </thead>
87 <tbody>
88 <tr>
89 <td>{{ contribution.transaction.id }}</td>
90 <td>{{ contribution.transaction.description }}</td>
91 <td>{{ contribution.transaction.date }}</td>
92 <td>{{ memberName({'id': mid}) }}</td>
93 <td class="right">{{ contribution.transaction.amount }}</td>
94 <td class="right">{{ contribution.transaction.getMissingAmount() }}</td>
95 <td>
96 <a
97 href="{{ url_for("editTransaction", {"id": contribution.transaction.id}) }}"
98 >
99 <i class="eye outline blue icon tooltip"></i>
100 <span class="ui special popup">{{ _T("View transaction") }}</span>
101 </a>
102 {% if contribution.isTransactionPart() and contribution.transaction.getMissingAmount() > 0 %}
103 <a
104 href="{{ url_for("addContribution", {"type": constant('Galette\\Entity\\Contribution::TYPE_FEE')}) }}?trans_id={{ contribution.transaction.id }}"
105 >
106 <i class="receipt green icon tooltip"></i>
107 <span class="ui special popup">{{ _T("New attached fee") }}</span>
108 </a>
109 <a
110 href="{{ url_for("addContribution", {"type": "donation"}) }}?trans_id={{ contribution.transaction.id }}"
111 >
112 <i class="gift green icon tooltip"></i>
113 <span class="ui special popup">{{ _T("New attached donation") }}</span>
114 </a>
115 {% endif %}
116 </td>
117 </tr>
118 </tbody>
119 </table>
120 </div>
121 {% endif %}
122 </div>
123 </div>
124 </div>
125
126 <div class="ui styled fluid accordion field">
127 <div class="active title">
128 <i class="jsonly displaynone icon dropdown"></i>
129 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}
130 {{ _T("Details of membership fee") }}
131 {% else %}
132 {{ _T("Details of donation") }}
133 {% endif %}
134 </div>
135 <div class="active content field">
136 <div id="contribdetails" class="ui basic fitted segment">
137 <div class="two fields">
138 <div class="field">
139 <label for="montant_cotis">{{ _T("Amount:") }}</label>
140 <input type="text" name="montant_cotis" id="montant_cotis" value="{{ contribution.amount }}" maxlength="10"{% if required.montant_cotis == 1 %} required="required"{% endif %}/>
141 </div>
142 {# payment type #}
143 {% set ptype = contribution.payment_type %}
144 {% if ptype == null %}
145 {% set ptype = constant('Galette\\Entity\\PaymentType::CHECK') %}
146 {% endif %}
147 {% include 'components/forms/payment_types.html.twig' with {'current': ptype, 'varname': 'type_paiement_cotis', 'show_inline': true} %}
148 </div>
149 <div class="{% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}three{% else %}two{% endif %} fields">
150 <div class="field">
151 <label for="date_enreg">
152 {{ _T("Record date:") }}
153 </label>
154 <div class="ui calendar" id="contribution-rangestart">
155 <div class="ui input left icon">
156 <i class="calendar icon"></i>
157 <input type="text" name="date_enreg" id="date_enreg" value="{{ contribution.date }}" maxlength="10"{% if required.date_enreg == 1 %} required="required"{% endif %}>
158 </div>
159 </div>
160 <span class="exemple">{{ _T("(yyyy-mm-dd format)") }}</span>
161 </div>
162 <div class="field">
163 <label for="date_debut_cotis">
164 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}
165 {{ _T("Start date of membership:") }}
166 {% else %}
167 {{ _T("Date of contribution:") }}
168 {% endif %}
169 </label>
170 <div class="ui calendar" id="contribution-rangeend">
171 <div class="ui input left icon">
172 <i class="calendar icon"></i>
173 <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 %}/>
174 </div>
175 </div>
176 <span class="exemple">{{ _T("(yyyy-mm-dd format)") }}</span>
177 </div>
178 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') %}
179 <div class="field">
180 {% if preferences.pref_membership_ext != "" %}
181 <label for="duree_mois_cotis">{{ _T("Membership extension:") }}</label>
182 <input type="text" name="duree_mois_cotis" id="duree_mois_cotis" value="{{ contribution.duration }}" maxlength="3"{% if required.date_fin_cotis == 1%} required="required"{% endif %}/>
183 <span class="exemple">{{ _T("months") }}</span>
184 {% else %}
185 <label for="date_fin_cotis">{{ _T("End date of membership:") }}</label>
186 <input type="text" name="date_fin_cotis" id="date_fin_cotis" value="{{ contribution.end_date }}" maxlength="10"{% if required.date_fin_cotis == 1 %} required="required"{% endif %}/>
187 <span class="exemple">{{ _T("(yyyy-mm-dd format)") }}</span>
188 {% endif %}
189 </div>
190 {% endif %}
191 </div>
192 <div class="field">
193 <label for="info_cotis">{{ _T("Comments:") }}</label>
194 <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>
195 </div>
196 </div>
197 </div>
198 </div>
199
200 {% include 'components/dynamic_fields.html.twig' with {'object': contribution} %}
201
202 {% if not contribution.id and preferences.pref_mail_method != constant('Galette\\Core\\GaletteMail::METHOD_DISABLED') %}
203 {% if not require_mass %}
204 <div class="ui center aligned yellow segment">
205 <div class="inline field">
206 <div class="ui toggle checkbox">
207 <input type="checkbox" name="mail_confirm" id="mail_confirm" value="1"{% if contribution.sendEMail() %} checked="checked"{% endif %}/>
208 <label for="mail_confirm">
209 {{ _T("Notify member") }}
210 </label>
211 <br/>
212 <span class="exemple">
213 {{ _T("Member will receive a notification by email, if he has an address.") }}
214 </span>
215 </div>
216 </div>
217 </div>
218 {% endif %}
219 {% endif %}
220 {% if not require_mass %}
221 <div class="ui basic center aligned segment">
222 <button type="submit" name="valid" class="ui labeled icon primary button action">
223 <i class="save icon"></i> {{ _T("Save") }}
224 </button>
225 <input type="hidden" name="id_cotis" value="{{ contribution.id }}"/>
226 <input type="hidden" name="valid" value="1"/>
227 <input type="hidden" name="trans_id" value="{% if contribution.transaction != NULL %}{{ contribution.transaction.id }}{% endif %}"/>
228 </div>
229 {% endif %}
230 {% if mode != 'ajax' %}
231 {% include "components/forms/csrf.html.twig" %}
232 </form>
233 {% endif %}
234 {% elseif mode != 'ajax' %} {# No members #}
235 <div class="ui warning message" id="warningbox">
236 <h3>{{ _T("No member registered!") }}</h3>
237 <p>
238 {{ _T("Unfortunately, there is no member in your database yet,") }}
239 <br/>
240 <a href="{{ url_for("addMember") }}">{{ _T("please create a member") }}</a>
241 </p>
242 </div>
243 {% endif %}
244 {% endblock %}
245
246 {% block javascripts %}
247 <script type="text/javascript">
248 {% include "elements/js/choose_adh.js.twig" %}
249 document.getElementById('id_adh_input').type = 'hidden';
250
251 $(function() {
252
253 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') and not contribution.id %}
254 $('#id_adh, #id_type_cotis').on('change', function() {
255 var _this = $(this);
256 var _member = $('#id_adh').val();
257 var _fee = $('#id_type_cotis').val();
258
259 $.ajax({
260 type: 'POST',
261 dataType: 'json',
262 url : '{{ url_for("contributionDates") }}',
263 data: {
264 member_id: _member,
265 fee_id: _fee
266 },
267 {% include "elements/js/loader.js.twig" with {
268 selector: '#contribdetails'
269 } %},
270 success: function(res){
271 $('#date_debut_cotis').val(res.date_debut_cotis);
272 $('#date_fin_cotis').val(res.date_fin_cotis);
273 },
274 error: function() {
275 {% include "elements/js/modal.js.twig" with {
276 modal_title_twig: _T("An error occurred retrieving dates :(")|e("js"),
277 modal_without_content: true,
278 modal_class: "mini",
279 modal_deny_only: true,
280 modal_cancel_text: _T("Close")|e("js"),
281 modal_classname: "redalert",
282 } %}
283 }
284 });
285
286 });
287 {% endif %}
288
289 {% if contribution.isTransactionPart() and contribution.transaction.getMissingAmount() %}
290 $('#transaction_related').hide();
291 $('#montant_cotis').on('keyup', function() {
292 var _amount = {{ contribution.transaction.getMissingAmount() }};
293 var _current = $(this).val();
294 if (_current < _amount) {
295 $('#transaction_related').show();
296 } else if (_current > _amount) {
297 {% include "elements/js/modal.js.twig" with {
298 modal_title_twig: _T("Contribution amount should not be greater than %max")|replace({'%max': contribution.transaction.getMissingAmount()})|e("js"),
299 modal_without_content: true,
300 modal_class: "mini",
301 modal_deny_only: true,
302 modal_cancel_text: _T("Close")|e("js"),
303 modal_classname: "redalert",
304 } %}
305 } else {
306 $('#transaction_related').hide();
307 }
308 });
309 {% endif %}
310 });
311 </script>
312 {% endblock %}