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