]> git.agnieray.net Git - galette.git/blob - galette/templates/default/ajouter_transaction.tpl
a566e717c21cafba9ee0d9ff58d66e7b19b67490
[galette.git] / galette / templates / default / ajouter_transaction.tpl
1 {extends file="page.tpl"}
2
3 {block name="content"}
4 {if isset($members.list)}
5 <form action="{if $transaction->id}{path_for name="editTransaction" data=["id" => $transaction->id]}{else}{path_for name="addTransaction"}{/if}" method="post">
6 <div class="bigtable">
7 <fieldset class="cssform">
8 <legend class="ui-state-active ui-corner-top">{_T string="Transaction details"}</legend>
9 <p>
10 <label for="trans_desc" class="bline">{_T string="Description:"}</label>
11 <input type="text" name="trans_desc" id="trans_desc" value="{$transaction->description}" maxlength="150" size="30"{if $required.trans_desc eq 1} required="required"{/if}/>
12 </p>
13 <p>
14 <label for="id_adh" class="bline" >{_T string="Originator:"}</label>
15 <select name="id_adh" id="id_adh" class="nochosen"{if $required.id_adh eq 1} required="required"{/if}>
16 {if !$transaction->member}
17 <option value="">{_T string="-- select a name --"}</option>
18 {/if}
19 {foreach $members.list as $k=>$v}
20 <option value="{$k}"{if $transaction->member == $k} selected="selected"{/if}>{$v}</option>
21 {/foreach}
22 </select>
23 </p>
24 <p>
25 <label for="trans_date" class="bline">{_T string="Date:"}</label>
26 <input type="text" class="date-pick" name="trans_date" id="trans_date" value="{$transaction->date}" maxlength="10"{if $required.trans_date eq 1} required="required"{/if}/> <span class="exemple">{_T string="(yyyy-mm-dd format)"}</span>
27 </p>
28 <p>
29 <label for="trans_amount" class="bline">{_T string="Amount:"}</label>
30 <input type="text" name="trans_amount" id="trans_amount" value="{$transaction->amount}" maxlength="10"{if $required.trans_amount eq 1} required="required"{/if}/>
31 </p>
32 {if $transaction->id eq null or $transaction->getMissingAmount() > 0}
33 <p>
34 <span class="bline tooltip" title="{_T string="Select a contribution type to create for dispatch transaction"}">{_T string="Dispatch type:"}</span>
35 <span class="tip">{_T string="Select a contribution type to create for dispatch transaction"}</span>
36 <input type="radio" name="contrib_type" id="contrib_type_fee" value="fee" checked="checked"/> <label for="contrib_type_fee">{_T string="Membership fee"}</label>
37 <input type="radio" name="contrib_type" id="contrib_type_donation" value="donation"/> <label for="contrib_type_donation">{_T string="Donation"}</label>
38 </p>
39 {/if}
40 </fieldset>
41 </div>
42 {include file="edit_dynamic_fields.tpl" object=$transaction}
43 <div class="button-container">
44 <button type="submit" name="valid" class="action">
45 <i class="fas fa-save fa-fw"></i> {_T string="Save"}
46 </button>
47 <input type="hidden" name="trans_id" value="{$transaction->id}"/>
48 <input type="hidden" name="valid" value="1"/>
49 </div>
50 <p>{_T string="NB : The mandatory fields are in"} <span class="required">{_T string="red"}</span></p>
51 {if $transaction->id}
52 </form>
53 <table class="listing">
54 <caption>
55 {_T string="Attached contributions"}
56 {if $transaction->getMissingAmount() > 0}
57 <a
58 href="{path_for name="addContribution" data=["type" => "fee"]}?trans_id={$transaction->id}"
59 class="button fright tooltip"
60 >
61 <i class="fas fa-user-check"></i>
62 <span class="sr-only">{_T string="Create a new fee that will be attached to the current transaction"}</span>
63 </a>
64 <a
65 href="{path_for name="addContribution" data=["type" => "donation"]}?trans_id={$transaction->id}"
66 class="button fright tooltip"
67 >
68 <i class="fas fa-gift"></i>
69 <span class="sr-only">{_T string="Create a new donation that will be attached to the current transaction"}</span>
70 </a>
71 <a
72 href="#"
73 class="button fright tooltip"
74 id="contribslist"
75 >
76 <i class="fas fa-cookie"></i>
77 <span class="sr-only">{_T string="Select an existing contribution in the database, and attach it to the current transaction"}</span>
78 </a>
79 {/if}
80 </caption>
81 <thead>
82 <tr>
83 <th class="id_row">#</th>
84 <th class="left date_row">{_T string="Date"}</th>
85 <th class="left date_row">{_T string="Begin"}</th>
86 <th class="left date_row">{_T string="End"}</th>
87 <th class="left">{_T string="Duration"}</th>
88 {if $login->isAdmin() or $login->isStaff()}
89 <th class="left">{_T string="Member"}</th>
90 {/if}
91 <th class="left">{_T string="Type"}</th>
92 <th class="left">{_T string="Amount"}</th>
93 {if $login->isAdmin() or $login->isStaff()}
94 <th class="actions_row"></th>
95 {/if}
96 </tr>
97 </thead>
98 <tfoot>
99 <tr>
100 <th class="right bgfree" colspan="{if $login->isAdmin() or $login->isStaff()}7{else}5{/if}">{_T string="Dispatched amount:"}</th>
101 <th class="right bgfree">{$transaction->getDispatchedAmount()}</th>
102 <td></td>
103 </tr>
104 <tr>
105 <th class="right bgfree" colspan="{if $login->isAdmin() or $login->isStaff()}7{else}5{/if}">{_T string="Not dispatched amount:"}</th>
106 <th class="right bgfree">{$transaction->getMissingAmount()}</th>
107 <td></td>
108 </tr>
109 </tfoot>
110 <tbody>
111 {foreach from=$contribs item=contrib key=ordre}
112 {assign var="mid" value=$contrib->member}
113 {assign var="cclass" value=$contrib->getRowClass()}
114 <tr>
115 <td class="{$cclass} center nowrap">
116 {$ordre+1}
117 </td>
118 <td class="{$cclass} center nowrap">{$contrib->date}</td>
119 <td class="{$cclass} center nowrap">{$contrib->begin_date}</td>
120 <td class="{$cclass} center nowrap">{$contrib->end_date}</td>
121 <td class="{$cclass} nowrap">{$contrib->duration}</td>
122 {if $login->isAdmin() or $login->isStaff()}
123 <td class="{$cclass}">{memberName id="$mid"}</td>
124 {/if}
125 <td class="{$cclass}">{$contrib->type->libelle}</td>
126 <td class="{$cclass} nowrap right">{$contrib->amount}</td>
127 {if $login->isAdmin() or $login->isStaff()}
128 <td class="{$cclass} actions_row">
129 <a
130 href="{path_for name="detach_contribution" data=["id" => $transaction->id, "cid" => $contrib->id]}"
131 class="delete tooltip"
132 >
133 <i class="fas fa-trash"></i>
134 <span class="sr-only">{_T string="Detach contribution from this transaction"}</span>
135 </a>
136 </td>
137 {/if}
138 </tr>
139 {foreachelse}
140 <tr><td colspan="{if $login->isAdmin() or $login->isStaff()}9{else}7{/if}" class="emptylist">{_T string="no contribution"}</td></tr>
141 {/foreach}
142 </tbody>
143 </table>
144 {/if}
145 {else} {* No members *}
146 <div class="center" id="warningbox">
147 <h3>{_T string="No member registered!"}</h3>
148 <p>
149 {_T string="Unfortunately, there is no member in your database yet,"}
150 <br/>
151 <a href="{path_for name="addMember"}">{_T string="please create a member"}</a>
152 </p>
153 </div>
154 {/if}
155 {/block}
156
157 {block name="javascripts"}
158 <script type="text/javascript">
159 {include file="js_chosen_adh.tpl"}
160 $(function(){
161 {if $transaction->id}
162 $('#contribslist').click(function(){
163 $.ajax({
164 url: '{path_for name="contributions" data=["type" => "contributions"]}',
165 type: "GET",
166 data: {
167 ajax: true,
168 max_amount: '{$transaction->getMissingAmount()}'
169 },
170 {include file="js_loader.tpl"},
171 success: function(res){
172 _contribs_dialog(res);
173 },
174 error: function() {
175 alert("{_T string="An error occurred displaying members interface :("}");
176 }
177 });
178 return false;
179 });
180
181 var _contribs_dialog = function(res){
182 var _el = $('<div id="contributions_list" title="{_T string="Contributions selection"}"> </div>');
183 _el.appendTo('body').dialog({
184 modal: true,
185 hide: 'fold',
186 width: '80%',
187 height: 500,
188 close: function(event, ui){
189 _el.remove();
190 $("#legende").remove();
191 }
192 });
193 _contribs_ajax_mapper(res);
194 }
195
196 var _contribs_ajax_mapper = function(res){
197 $("#contributions_list #legende").remove();
198 $('#contributions_list').append( res );
199
200 //Deactivate contributions list links
201 $('#contributions_list tbody a').click(function(){
202 //for links in body (members links), we de nothing
203 return false;
204 });
205 _bindNbshow('#contributions_list #filtre');
206 //Use JS to send form
207 $('#contributions_list #filtre').submit(function(){
208 $.ajax({
209 url: this.action,
210 type: "POST",
211 data: $("#filtre").serialize(),
212 {include file="js_loader.tpl"},
213 success: function(res){
214 $('#contributions_list').empty();
215 _contribs_ajax_mapper(res);
216 },
217 error: function() {
218 alert("{_T string="An error occurred displaying contributions :("}");
219 }
220 });
221 return false;
222 });
223 //Bind pagination links
224 $('#contributions_list .pages a').bind({
225 click: function(){
226 $.ajax({
227 url: this.href.substring(this.href.indexOf('?')) + (this.href.indexOf('?') > -1 ? "&" : "?") + "ajax=true",
228 type: "GET",
229 {include file="js_loader.tpl"},
230 success: function(res){
231 $('#contributions_list').empty();
232 _contribs_ajax_mapper(res);
233 },
234 error: function() {
235 alert("{_T string="An error occurred displaying contributions :("}");
236 },
237 });
238 return false;
239 }
240 });
241 //Select a row
242 $('#contributions_list .contribution_row').click(function(){
243 $('#contributions_list').dialog("close");
244 var _cid = $(this).find('input[name="contrib_id"]').val();
245 window.location.href = '{path_for name="attach_contribution" data=["id" => $transaction->id, "cid" => "%cid"]}'.replace(/%cid/, _cid);
246 }).css('cursor', 'pointer').attr('title', '{_T string="Click on a contribution row to attach it to the current transaction" escape="js"}');
247 }
248 {/if}
249 $('#trans_date').datepicker({
250 changeMonth: true,
251 changeYear: true,
252 showOn: 'button',
253 buttonText: '<i class="far fa-calendar-alt"></i> <span class="sr-only">{_T string="Select a date" escape="js"}</span>'
254 });
255 });
256 </script>
257 {/block}