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