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