]> git.agnieray.net Git - galette.git/blob - galette/templates/default/ajouter_contribution.tpl
Add CSRF Middleware
[galette.git] / galette / templates / default / ajouter_contribution.tpl
1 {if isset($mode) && $mode eq 'ajax'}
2 {assign var="extend" value='ajax.tpl'}
3 {else}
4 {assign var="extend" value='page.tpl'}
5 {/if}
6 {extends file=$extend}
7
8 {block name="content"}
9 {if isset($members.list) || $require_mass}
10 <form action="{if $contribution->id}{path_for name="doEditContribution" data=["type" => $type, "id" => $contribution->id]}{else}{path_for name="doAddContribution" data=["type" => $type]}{/if}" enctype="multipart/form-data" method="post">
11 <div class="bigtable">
12 {if $contribution->isTransactionPart()}
13 {assign var="mid" value=$contribution->transaction->member}
14 <table id="transaction_detail">
15 <caption>{_T string="Related transaction information"}</caption>
16 <thead>
17 <tr>
18 <td colspan="5">
19 {$contribution->transaction->description}
20 <a href="{path_for name="editTransaction" data=["id" => $contribution->transaction->id]}" title="{_T string="View transaction"}">
21 <img src="{base_url}/{$template_subdir}images/icon-money.png"
22 alt="{_T string="[view]"}"
23 width="16"
24 height="16"/>
25 </a>
26 </td>
27 </tr>
28 </thead>
29 <tbody>
30 <tr>
31 <th class="listing">#</th>
32 <th class="listing">{_T string="Date"}</th>
33 <th class="listing">{_T string="Member"}</th>
34 <th class="listing">{_T string="Amount"}</th>
35 <th class="listing">{_T string="Not dispatched amount"}</th>
36 </tr>
37 <tr>
38 <td>{$contribution->transaction->id}</td>
39 <td>{$contribution->transaction->date}</td>
40 <td>{memberName id="$mid"}</td>
41 <td class="right">{$contribution->transaction->amount}</td>
42 <td class="right">{$contribution->transaction->getMissingAmount()}</td>
43 </tr>
44 </tbody>
45 </table>
46 {/if}
47 <p>{_T string="NB : The mandatory fields are in"} <span class="required">{_T string="red"}</span></p>
48 <fieldset class="cssform">
49 <legend class="ui-state-active ui-corner-top">
50 {if $type eq constant('Galette\Entity\Contribution::TYPE_FEE')}
51 {_T string="Select contributor and membership fee type"}
52 {else}
53 {_T string="Select contributor and donation type"}
54 {/if}
55 {if $contribution->isTransactionPart() && $contribution->transaction->getMissingAmount() > 0}
56 <a
57 href="{path_for name="addContribution" data=["type" => constant('Galette\Entity\Contribution::TYPE_FEE')]}?trans_id={$contribution->transaction->id}"
58 class="button fright tooltip"
59 title="{_T string="Create a new fee that will be attached to the current transaction"}">
60 <i class="fas fa-user-check"></i>
61 <span class="sr-only">{_T string="New attached fee"}</span>
62 </a>
63 <a
64 href="{path_for name="addContribution" data=["type" => "donation"]}?trans_id={$contribution->transaction->id}"
65 class="button fright tooltip"
66 title="{_T string="Create a new donation that will be attached to the current transaction"}">
67 <i class="fas fa-gift"></i>
68 <span class="sr-only">{_T string="New attached donation"}</span>
69 </a>
70 {/if}
71 </legend>
72 {if !$require_mass}
73 <p>
74 <label for="id_adh" class="bline">{_T string="Contributor:"}</label>
75 <select name="id_adh" id="id_adh" class="nochosen">
76 {if $adh_selected eq 0}
77 <option value="">{_T string="Search for name or ID and pick member"}</option>
78 {/if}
79 {foreach $members.list as $k=>$v}
80 <option value="{$k}"{if $contribution->member == $k} selected="selected"{/if}>{$v}</option>
81 {/foreach}
82 </select>
83 </p>
84 {/if}
85 <p>
86 <label for="id_type_cotis" class="bline">{_T string="Contribution type:"}</label>
87 <select name="id_type_cotis" id="id_type_cotis"{if isset($required.id_type_cotis) && ($required.id_type_cotis eq 1)} required="required"{/if}>
88 {if $contribution->type}
89 {assign var="selectedid" value=$contribution->type->id}
90 {else}
91 {assign var="selectedid" value=null}
92 {/if}
93 {html_options options=$type_cotis_options selected=$selectedid}
94 </select>
95 </p>
96 {if $type eq constant('Galette\Entity\Contribution::TYPE_FEE')}
97 <noscript>
98 <div class="button-container" id="reloadcont">
99 <input type="submit" id="btnreload" name="btnreload" value="{_T string="Reload"}" title="{_T string="Reload date information according to selected member and contribution type"}"/>
100 </div>
101 </noscript>
102 {/if}
103 </fieldset>
104
105 <fieldset class="cssform">
106 <legend class="ui-state-active ui-corner-top">{if $type eq constant('Galette\Entity\Contribution::TYPE_FEE')}{_T string="Details of membership fee"}{else}{_T string="Details of donation"}{/if}</legend>
107 <p>
108 <label class="bline" for="montant_cotis">{_T string="Amount:"}</label>
109 <input type="text" name="montant_cotis" id="montant_cotis" value="{$contribution->amount}" maxlength="10"{if isset($required.montant_cotis) && ($required.montant_cotis eq 1)} required="required"{/if}/>
110 </p>
111 {* payment type *}
112 {assign var="ptype" value=$contribution->payment_type}
113 {if $ptype == null}
114 {assign var="ptype" value=constant('Galette\Entity\PaymentType::CHECK')}
115 {/if}
116 {include file="forms_types/payment_types.tpl" current=$ptype varname="type_paiement_cotis"}
117 <p>
118 <label class="bline" for="date_enreg">
119 {_T string="Record date:"}
120 </label>
121 <input class="past-date-pick" type="text" name="date_enreg" id="date_enreg" value="{$contribution->date}" maxlength="10"{if isset($required.date_enreg) && ($required.date_enreg eq 1)} required="required"{/if}/>
122 <span class="exemple">{_T string="(yyyy-mm-dd format)"}</span>
123 </p>
124
125 <p>
126 <label class="bline" for="date_debut_cotis">
127 {if $type eq constant('Galette\Entity\Contribution::TYPE_FEE')}
128 {_T string="Start date of membership:"}
129 {else}
130 {_T string="Date of contribution:"}
131 {/if}
132 </label>
133 <input class="past-date-pick" type="text" name="date_debut_cotis" id="date_debut_cotis" value="{$contribution->begin_date}" maxlength="10"{if isset($required.date_debut_cotis) && ($required.date_debut_cotis eq 1)} required="required"{/if}/>
134 <span class="exemple">{_T string="(yyyy-mm-dd format)"}</span>
135 </p>
136 {if $type eq constant('Galette\Entity\Contribution::TYPE_FEE')}
137 <p>
138 {if $preferences->pref_membership_ext != ""}
139 <label class="bline" for="duree_mois_cotis">{_T string="Membership extension:"}</label>
140 <input type="text" name="duree_mois_cotis" id="duree_mois_cotis" value="{$contribution->duration}" maxlength="3"{if isset($required.date_fin_cotis) && ($required.date_fin_cotis eq 1)} required="required"{/if}/>
141 <span class="exemple">{_T string="months"}</span>
142 {else}
143 <label class="bline" for="date_fin_cotis">{_T string="End date of membership:"}</label>
144 <input type="text" name="date_fin_cotis" id="date_fin_cotis" value="{$contribution->end_date}" maxlength="10"{if isset($required.date_fin_cotis) && ($required.date_fin_cotis eq 1)} required="required"{/if}/>
145 <span class="exemple">{_T string="(yyyy-mm-dd format)"}</span>
146 {/if}
147 </p>
148 {/if}
149 <p>
150 <label class="bline" for="info_cotis">{_T string="Comments:"}</label>
151 <textarea name="info_cotis" id="info_cotis" cols="61" rows="6"{if isset($required.info_cotis) and $required.info_cotis eq 1} required="required"{/if}>{$contribution->info}</textarea>
152 </p>
153 </fieldset>
154
155 {if $contribution->isTransactionPart() && $contribution->transaction->getMissingAmount()}
156 <fieldset class="cssform" id="transaction_related">
157 <legend class="ui-state-active ui-corner-top">{_T string="Transaction related"}</legend>
158 <p>
159 <span class="bline tooltip" title="{_T string="Select a contribution type to create for dispatch transaction"}">{_T string="Dispatch type:"}</span>
160 <span class="tip">{_T string="Select a contribution type to create for dispatch transaction"}</span>
161 <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 string="Membership fee"}</label>
162 <input type="radio" name="contrib_type" id="contrib_type_donation" value="donation"/> <label for="contrib_type_donation">{_T string="Donation"}</label>
163 </p>
164 </fieldset>
165 {/if}
166 {include file="edit_dynamic_fields.tpl" object=$contribution}
167 {if not $contribution->id and $pref_mail_method neq constant('Galette\Core\GaletteMail::METHOD_DISABLED')}
168 {if !$require_mass}
169 <p>
170 <label for="mail_confirm">{_T string="Notify member"}</label>
171 <input type="checkbox" name="mail_confirm" id="mail_confirm" value="1" {if $preferences->pref_bool_mailowner || isset($smarty.post.mail_confirm) and $smarty.post.mail_confirm != ""}checked="checked"{/if}/>
172 <br/><span class="exemple">{_T string="Member will receive a notification by email, if he has an address."}</span>
173 </p>
174 {/if}
175 {/if}
176 </div>
177 {if !$require_mass}
178 <div class="button-container">
179 <button type="submit" name="valid" class="action">
180 <i class="fas fa-save fa-fw"></i> {_T string="Save"}
181 </button>
182 <input type="hidden" name="id_cotis" value="{$contribution->id}"/>
183 <input type="hidden" name="valid" value="1"/>
184 <input type="hidden" name="trans_id" value="{if $contribution->transaction neq NULL}{$contribution->transaction->id}{/if}"/>
185 </div>
186 {/if}
187 {include file="forms_types/csrf.tpl"}
188 </form>
189 {else} {* No members *}
190 <div class="center" id="warningbox">
191 <h3>{_T string="No member registered!"}</h3>
192 <p>
193 {_T string="Unfortunately, there is no member in your database yet,"}
194 <br/>
195 <a href="{path_for name="addMember"}">{_T string="please create a member"}</a>
196 </p>
197 </div>
198 {/if}
199 {/block}
200
201 {block name="javascripts"}
202 <script type="text/javascript">
203 {include file="js_chosen_adh.tpl"}
204
205 $(function() {
206 $('#date_debut_cotis, #date_fin_cotis, #date_enreg').datepicker({
207 changeMonth: true,
208 changeYear: true,
209 showOn: 'button',
210 buttonText: '<i class="far fa-calendar-alt"></i> <span class="sr-only">{_T string="Select a date" escape="js"}</span>'
211 });
212
213 {if $type eq constant('Galette\Entity\Contribution::TYPE_FEE') and !$contribution->id}
214 $('#id_adh, #id_type_cotis').on('change', function() {
215 var _this = $(this);
216 var _member = $('#id_adh').val();
217 var _fee = $('#id_type_cotis').val();
218
219 $.ajax({
220 type: 'POST',
221 dataType: 'json',
222 url : '{path_for name="contributionDates"}',
223 data: {
224 member_id: _member,
225 fee_id: _fee
226 },
227 {include file="js_loader.tpl"},
228 success: function(res){
229 $('#date_debut_cotis').val(res.date_debut_cotis);
230 $('#date_fin_cotis').val(res.date_fin_cotis);
231 },
232 error: function() {
233 alert("{_T string="An error occurred retrieving dates :(" escape="js"}");
234 }
235 });
236
237 });
238 {/if}
239
240 {if $contribution->isTransactionPart() && $contribution->transaction->getMissingAmount()}
241 $('#transaction_related').hide();
242 $('#montant_cotis').on('keyup', function() {
243 var _amount = {$contribution->transaction->getMissingAmount()};
244 var _current = $(this).val();
245 if (_current < _amount) {
246 $('#transaction_related').show();
247 } else if (_current > _amount) {
248 alert('{_T string="Contribution amount should be greater than %max" pattern="/%max/" replace=$contribution->transaction->getMissingAmount() escape="js"}');
249 } else {
250 $('#transaction_related').hide();
251 }
252 });
253 {/if}
254 });
255 </script>
256 {/block}