]> git.agnieray.net Git - galette.git/blob - galette/templates/default/pages/contribution_form.html.twig
1aa824503e8bc796dfe15ef6f5821c729545274b
[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="hidden" 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{% 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") }}"></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 <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{% if required.montant_cotis is defined and required.montant_cotis == 1 %} required{% endif %}">
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 is defined and 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{% if required.date_enreg is defined and required.date_enreg == 1 %} required{% endif %}">
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 is defined and 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{% if required.date_debut_cotis is defined and required.date_debut_cotis == 1 %} required{% endif %}">
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{% if required.date_fin_cotis is defined and required.date_fin_cotis == 1 %} required{% endif %}">
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 is defined and 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 <div class="ui calendar" id="membership-rangeend">
187 <div class="ui input left icon">
188 <i class="calendar icon"></i>
189 <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 %}/>
190 </div>
191 </div>
192 <span class="exemple">{{ _T("(yyyy-mm-dd format)") }}</span>
193 {% endif %}
194 </div>
195 {% endif %}
196 </div>
197 <div class="field{% if required.info_cotis is defined and required.info_cotis == 1 %} required{% endif %}">
198 <label for="info_cotis">{{ _T("Comments:") }}</label>
199 <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>
200 </div>
201 </div>
202 </div>
203 </div>
204
205 {% include 'components/dynamic_fields.html.twig' with {'object': contribution} %}
206
207 {% if not contribution.id and preferences.pref_mail_method != constant('Galette\\Core\\GaletteMail::METHOD_DISABLED') %}
208 {% if not require_mass %}
209 <div class="ui center aligned yellow segment">
210 <div class="inline field">
211 <div class="ui toggle checkbox">
212 <input type="checkbox" name="mail_confirm" id="mail_confirm" value="1"{% if contribution.sendEMail() %} checked="checked"{% endif %}/>
213 <label for="mail_confirm">
214 {{ _T("Notify member") }}
215 </label>
216 <br/>
217 <span class="exemple">
218 {{ _T("Member will receive a notification by email, if he has an address.") }}
219 </span>
220 </div>
221 </div>
222 </div>
223 {% endif %}
224 {% endif %}
225 {% if not require_mass %}
226 <div class="ui basic center aligned segment">
227 <button type="submit" name="valid" class="ui labeled icon primary button action">
228 <i class="save icon"></i> {{ _T("Save") }}
229 </button>
230 <input type="hidden" name="id_cotis" value="{{ contribution.id }}"/>
231 <input type="hidden" name="valid" value="1"/>
232 <input type="hidden" name="trans_id" value="{% if contribution.transaction != NULL %}{{ contribution.transaction.id }}{% endif %}"/>
233 </div>
234 {% endif %}
235 {% if mode != 'ajax' %}
236 {% include "components/forms/csrf.html.twig" %}
237 </form>
238 {% endif %}
239 {% elseif mode != 'ajax' %} {# No members #}
240 <div class="ui warning message" id="warningbox">
241 <h3>{{ _T("No member registered!") }}</h3>
242 <p>
243 {{ _T("Unfortunately, there is no member in your database yet,") }}
244 <br/>
245 <a href="{{ url_for("addMember") }}">{{ _T("please create a member") }}</a>
246 </p>
247 </div>
248 {% endif %}
249 {% endblock %}
250
251 {% block javascripts %}
252 <script type="text/javascript">
253 {% include "elements/js/choose_adh.js.twig" %}
254
255 $(function() {
256
257 {% if type == constant('Galette\\Entity\\Contribution::TYPE_FEE') and not contribution.id %}
258 $('#id_adh, #id_type_cotis').on('change', function() {
259 var _this = $(this);
260 var _member = $('#id_adh').val();
261 var _fee = $('#id_type_cotis').val();
262
263 $.ajax({
264 type: 'POST',
265 dataType: 'json',
266 url : '{{ url_for("contributionDates") }}',
267 data: {
268 member_id: _member,
269 fee_id: _fee
270 },
271 {% include "elements/js/loader.js.twig" with {
272 selector: '#contribdetails'
273 } %},
274 success: function(res){
275 $('#date_debut_cotis').val(res.date_debut_cotis);
276 $('#date_fin_cotis').val(res.date_fin_cotis);
277 },
278 error: function() {
279 {% include "elements/js/modal.js.twig" with {
280 modal_title_twig: _T("An error occurred retrieving dates :(")|e("js"),
281 modal_without_content: true,
282 modal_class: "mini",
283 modal_deny_only: true,
284 modal_cancel_text: _T("Close")|e("js"),
285 modal_classname: "redalert",
286 } %}
287 }
288 });
289
290 });
291 {% endif %}
292
293 {% if contribution.isTransactionPart() and contribution.transaction.getMissingAmount() %}
294 $('#transaction_related').hide();
295 $('#montant_cotis').on('keyup', function() {
296 var _amount = {{ contribution.transaction.getMissingAmount() }};
297 var _current = $(this).val();
298 if (_current < _amount) {
299 $('#transaction_related').show();
300 } else if (_current > _amount) {
301 {% include "elements/js/modal.js.twig" with {
302 modal_title_twig: _T("Contribution amount should not be greater than %max")|replace({'%max': contribution.transaction.getMissingAmount()})|e("js"),
303 modal_without_content: true,
304 modal_class: "mini",
305 modal_deny_only: true,
306 modal_cancel_text: _T("Close")|e("js"),
307 modal_classname: "redalert",
308 } %}
309 } else {
310 $('#transaction_related').hide();
311 }
312 });
313 {% endif %}
314 });
315 </script>
316 {% endblock %}