]> git.agnieray.net Git - galette.git/blob - galette/templates/default/ajouter_transaction.tpl
18a3ddde14451dca464ecd2c81bc7ccc0e8ec50c
[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}" enctype="multipart/form-data" 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="{constant('Galette\Entity\Contribution::TYPE_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="{constant('Galette\Entity\Contribution::TYPE_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 </form>
52
53 {if $transaction->id}
54 <table class="listing">
55 <caption>
56 {_T string="Attached contributions"}
57 {if $transaction->getMissingAmount() > 0}
58 <a
59 href="{path_for name="addContribution" data=["type" => constant('Galette\Entity\Contribution::TYPE_FEE')]}?trans_id={$transaction->id}"
60 class="button fright tooltip"
61 >
62 <i class="fas fa-user-check"></i>
63 <span class="sr-only">{_T string="Create a new fee that will be attached to the current transaction"}</span>
64 </a>
65 <a
66 href="{path_for name="addContribution" data=["type" => constant('Galette\Entity\Contribution::TYPE_DONATION')]}?trans_id={$transaction->id}"
67 class="button fright tooltip"
68 >
69 <i class="fas fa-gift"></i>
70 <span class="sr-only">{_T string="Create a new donation that will be attached to the current transaction"}</span>
71 </a>
72 <a
73 href="#"
74 class="button fright tooltip"
75 id="contribslist"
76 >
77 <i class="fas fa-cookie"></i>
78 <span class="sr-only">{_T string="Select an existing contribution in the database, and attach it to the current transaction"}</span>
79 </a>
80 {/if}
81 </caption>
82 <thead>
83 <tr>
84 <th class="id_row">#</th>
85 <th class="left date_row">{_T string="Date"}</th>
86 <th class="left date_row">{_T string="Begin"}</th>
87 <th class="left date_row">{_T string="End"}</th>
88 <th class="left">{_T string="Duration"}</th>
89 {if $login->isAdmin() or $login->isStaff()}
90 <th class="left">{_T string="Member"}</th>
91 {/if}
92 <th class="left">{_T string="Type"}</th>
93 <th class="left">{_T string="Amount"}</th>
94 {if $login->isAdmin() or $login->isStaff()}
95 <th class="actions_row"></th>
96 {/if}
97 </tr>
98 </thead>
99 <tfoot>
100 <tr>
101 <th class="right bgfree" colspan="{if $login->isAdmin() or $login->isStaff()}7{else}5{/if}">{_T string="Dispatched amount:"}</th>
102 <th class="right bgfree">{$transaction->getDispatchedAmount()}</th>
103 <td></td>
104 </tr>
105 <tr>
106 <th class="right bgfree" colspan="{if $login->isAdmin() or $login->isStaff()}7{else}5{/if}">{_T string="Not dispatched amount:"}</th>
107 <th class="right bgfree">{$transaction->getMissingAmount()}</th>
108 <td></td>
109 </tr>
110 </tfoot>
111 <tbody>
112 {foreach from=$contribs item=contrib key=ordre}
113 {assign var="mid" value=$contrib->member}
114 {assign var="cclass" value=$contrib->getRowClass()}
115 <tr>
116 <td class="{$cclass} center nowrap">
117 {$ordre+1}
118 </td>
119 <td class="{$cclass} center nowrap">{$contrib->date}</td>
120 <td class="{$cclass} center nowrap">{$contrib->begin_date}</td>
121 <td class="{$cclass} center nowrap">{$contrib->end_date}</td>
122 <td class="{$cclass} nowrap">{$contrib->duration}</td>
123 {if $login->isAdmin() or $login->isStaff()}
124 <td class="{$cclass}">{memberName id="$mid"}</td>
125 {/if}
126 <td class="{$cclass}">{$contrib->type->libelle}</td>
127 <td class="{$cclass} nowrap right">{$contrib->amount}</td>
128 {if $login->isAdmin() or $login->isStaff()}
129 <td class="{$cclass} actions_row">
130 <a
131 href="{path_for name="detach_contribution" data=["id" => $transaction->id, "cid" => $contrib->id]}"
132 class="delete tooltip"
133 >
134 <i class="fas fa-trash"></i>
135 <span class="sr-only">{_T string="Detach contribution from this transaction"}</span>
136 </a>
137 </td>
138 {/if}
139 </tr>
140 {foreachelse}
141 <tr><td colspan="{if $login->isAdmin() or $login->isStaff()}9{else}7{/if}" class="emptylist">{_T string="no contribution"}</td></tr>
142 {/foreach}
143 </tbody>
144 </table>
145 {/if}
146 {else} {* No members *}
147 <div class="center" id="warningbox">
148 <h3>{_T string="No member registered!"}</h3>
149 <p>
150 {_T string="Unfortunately, there is no member in your database yet,"}
151 <br/>
152 <a href="{path_for name="addMember"}">{_T string="please create a member"}</a>
153 </p>
154 </div>
155 {/if}
156 {/block}
157
158 {block name="javascripts"}
159 <script type="text/javascript">
160 {include file="js_chosen_adh.tpl"}
161 $(function(){
162 {if $transaction->id}
163 $('#contribslist').click(function(){
164 $.ajax({
165 url: '{path_for name="contributions" data=["type" => "contributions"]}',
166 type: "GET",
167 data: {
168 ajax: true,
169 max_amount: '{$transaction->getMissingAmount()}'
170 },
171 {include file="js_loader.tpl"},
172 success: function(res){
173 _contribs_dialog(res);
174 },
175 error: function() {
176 alert("{_T string="An error occurred displaying members interface :("}");
177 }
178 });
179 return false;
180 });
181
182 var _contribs_dialog = function(res){
183 var _el = $('<div id="contributions_list" title="{_T string="Contributions selection"}"> </div>');
184 _el.appendTo('body').dialog({
185 modal: true,
186 hide: 'fold',
187 width: '80%',
188 height: 500,
189 close: function(event, ui){
190 _el.remove();
191 $("#legende").remove();
192 }
193 });
194 _contribs_ajax_mapper(res);
195 }
196
197 var _contribs_ajax_mapper = function(res){
198 $('#contributions_list').append( res );
199 $("#contributions_list #legende").remove();
200 $("#contributions_list i.fa-filter").remove();
201
202 //Deactivate contributions list links
203 $('#contributions_list tbody a').click(function(){
204 //for links in body (members links), we de nothing
205 return false;
206 });
207 _bindNbshow('#contributions_list #filtre');
208 //Use JS to send form
209 $('#contributions_list #filtre').submit(function(){
210 $.ajax({
211 url: this.action,
212 type: "POST",
213 data: $("#filtre").serialize(),
214 {include file="js_loader.tpl"},
215 success: function(res){
216 $('#contributions_list').empty();
217 _contribs_ajax_mapper(res);
218 },
219 error: function() {
220 alert("{_T string="An error occurred displaying contributions :("}");
221 }
222 });
223 return false;
224 });
225 //Bind pagination and ordering links
226 $('#contributions_list .pages a, #contributions_list thead a').bind({
227 click: function(){
228 $.ajax({
229 url: this.href.substring(this.href.indexOf('?')) + (this.href.indexOf('?') > -1 ? "&" : "?") + "ajax=true",
230 type: "GET",
231 {include file="js_loader.tpl"},
232 success: function(res){
233 $('#contributions_list').empty();
234 _contribs_ajax_mapper(res);
235 },
236 error: function() {
237 alert("{_T string="An error occurred displaying contributions :("}");
238 },
239 });
240 return false;
241 }
242 });
243 //Select a row
244 $('#contributions_list .contribution_row').click(function(){
245 $('#contributions_list').dialog("close");
246 var _cid = $(this).find('input[name="contrib_sel[]"]').val();
247 window.location.href = '{path_for name="attach_contribution" data=["id" => $transaction->id, "cid" => "%cid"]}'.replace(/%cid/, _cid);
248 }).css('cursor', 'pointer').attr('title', '{_T string="Click on a contribution row to attach it to the current transaction" escape="js"}');
249 }
250 {/if}
251 $('#trans_date').datepicker({
252 changeMonth: true,
253 changeYear: true,
254 showOn: 'button',
255 buttonText: '<i class="far fa-calendar-alt"></i> <span class="sr-only">{_T string="Select a date" escape="js"}</span>'
256 });
257 });
258 </script>
259 {/block}