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