Files
aem_moniteurs/aem_gestion/templates/crm/contact_lookup.pt
2023-06-22 10:34:18 +02:00

117 lines
3.0 KiB
XML

<metal:block use-macro="main_template">
<div metal:fill-slot="content">
<div class="alert alert-danger" tal:condition="message" tal:content="message" />
<div class="row">
<form id="member-search-form" class="form-horizontal" role="form" action="${url}" method="post">
<div class="form-group">
<label class="col-xs-4 control-label">Nom, Code ou No mobile du contact</label>
<div class="col-xs-8">
<input type="text" class="form-control" name="name" value="${name}" />
</div>
</div>
<!-- case a cocher "Afficher fiches cloturées" -->
<div class="form-group">
<div class="col-xs-offset-4 col-xs-8">
<input type="checkbox" name="cb_tous" value="cb_tous"
tal:attributes="checked cb_tous == 'oui' and 'checked' or None">
Afficher les fiches cloturées</input>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-4 col-xs-8">
<button class="btn btn-primary" id="submitButton" type="submit" name="form.submitted">
<span class="glyphicon glyphicon-search"></span>&nbsp;Rechercher</button>
</div>
</div>
</form>
</div><!-- row -->
<div class="row" tal:condition="nb > 0">
<table id="contacts_list" class="table table-striped table-bordered">
<thead>
<tr>
<th>Code</th>
<th>Nom, Prénom</th>
<th>Permis</th>
<th>Créé le</th>
<th>Tél. port.</th>
<th>C. postal</th>
<th>Statut</th>
</tr>
</thead>
</table>
<br />
<br />
</div>
<script>
$(document).ready(function() {
var dataSet = ${dt_data};
$.fn.dataTable.moment('DD/MM/YYYY');
$('#contacts_list').DataTable({
data: dataSet,
pageLength: 100,
bLengthChange: false,
language: {
url: 'https://cdn.datatables.net/plug-ins/1.10.16/i18n/French.json'
},
columnDefs: [
{ "targets": 0,
"render": function (data, type, full, meta) {
// ajouter un link vers le formulaire
return '<a href="/contact_edit/' + data + '">' + data + '</a>';
},
},
],
createdRow: function( row, data, dataIndex ) {
if ( data[6] == "Gagné" ) {
$('td', row).eq(6).css('background-color', 'LightGreen');
}
if ( data[6] == "Perdu" ) {
$('td', row).eq(6).css('background-color', 'LightPink');
}
},
order: [[ 1, "asc" ]]
});
$('#member-search-form').formValidation({
framework: 'bootstrap',
message: 'This value is not valid',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name: {
validators: {
notEmpty: {
message: 'Le nom ou le code est obligatoire'
},
stringLength: {
min: 2,
max: 30,
message: 'Le nom ou le code doit avoir de 2 à 30 caractères de long'
},
}
},
}
});
$('form input').on('keypress', function(e) {
var code = e.keyCode || e.which;
if (code === 13) {
e.preventDefault();
// simuler clic bouton submit
document.getElementById("submitButton").click();
}
});
});
</script>
</div>
</metal:block>