Skip to content

Commit

Permalink
Fix car history display
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Sep 25, 2023
1 parent 0c70dc4 commit 4b9995f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
7 changes: 2 additions & 5 deletions lib/GaletteAuto/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,8 @@ private function formatEntries()
{
for ($i = 0; $i < count($this->entries); $i++) {
//put a formatted date to show
//strftime output is ISO-8859-1...
$this->entries[$i]['formatted_date'] = strftime(
'%d %B %Y',
strtotime($this->entries[$i]['history_date'])
);
$date = new \DateTime($this->entries[$i]['history_date']);
$this->entries[$i]['formatted_date'] = $date->format(__('Y-m-d'));
//associate member to current history entry
$this->entries[$i]['owner']
= new Adherent($this->zdb, (int)$this->entries[$i]['id_adh']);
Expand Down
14 changes: 9 additions & 5 deletions templates/default/history.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends (mode == 'ajax') ? "ajax.html.twig" : "page.html.twig" %}

{% block content %}
{% if entries|length > 0 %}
<table id="listing">
<thead>
<tr>
Expand All @@ -22,8 +23,8 @@
</tr>
</thead>
<tbody>
{% for entry in entries %}
{% set owner = entry.owner %}
{% for entry in entries %}
{% set owner = entry.owner %}
<tr>
<td>{{ entry.formatted_date }}</td>
<td>
Expand All @@ -42,9 +43,12 @@
<td>{{ entry.color.value }}</td>
<td>{{ entry.state.value}}</td>
</tr>
{% else %}
<tr><td colspan="5" class="emptylist">{{ _T("no history entries", "auto") }}</td></tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
{% else %}
<div class="ui message">
<p>{{ _T("no history entries", "auto") }}</p>
</div>
{% endif %}
{% endblock %}
19 changes: 6 additions & 13 deletions templates/default/vehicles.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
});
{% if mode != 'new' %}
$('#state_history').click(function(){
$('#state_history').click(function() {
$.ajax({
url: this.href,
success: function(res){
Expand All @@ -345,18 +345,11 @@
return false;
});
var _history_dialog = function(res){
var _el = $('<div id="history_list" title="{{ _T("Car's history", "auto")|e('js') }}"> </div>');
_el.appendTo('#modifform').dialog({
modal: true,
hide: 'fold',
width: '60%',
height: 400,
close: function(event, ui){
_el.remove();
}
});
$('#history_list').append( res );
var _history_dialog = function(res) {
$('body').modal({
title: '{{ _T("Car's history", "auto")|e('js') }}',
content: res
}).modal('show');
}
{% endif %}
{% endif %}
Expand Down

0 comments on commit 4b9995f

Please sign in to comment.