Page to see global paybacks ok. TODO : Confirmation of paybacks

This commit is contained in:
Phyks 2013-09-24 14:50:05 +02:00
parent 003df4d333
commit faed9a9a37
10 changed files with 151 additions and 17 deletions

5
TODO
View File

@ -1,6 +1,9 @@
Issues : Issues :
======== ========
* Check CSRF everywhere ? * Check CSRF everywhere
* Close a global payback
* View see_paybacks in english
* Sort global paybacks DESC by DATE or id
Improvements : Improvements :
============== ==============

View File

@ -676,6 +676,28 @@
} }
break; break;
case "see_paybacks":
$global_paybacks = new GlobalPayback();
if(empty($_GET['id'])) {
$global_paybacks = $global_paybacks->load();
}
else {
$global_paybacks = $global_paybacks->load(array('id'=>(int) $_GET['id']), true);
$tpl->assign('id', (int) $_GET['id']);
$users_list = new User();
$users_list = $users_list->load();
$tpl->assign('users', $users_list);
}
$tpl->assign('list', true);
$tpl->assign('global_paybacks', $global_paybacks);
$tpl->draw('see_paybacks');
break;
case "manage_paybacks": case "manage_paybacks":
if(empty($_GET['new'])) { if(empty($_GET['new'])) {
$global_paybacks = new GlobalPayback(); $global_paybacks = new GlobalPayback();
@ -766,8 +788,6 @@
} }
} }
var_dump($users_in);
$global_payback->setUsersIn($users_in); $global_payback->setUsersIn($users_in);
$global_payback->setDate(date('i'), date('G'), date('j'), date('n'), date('Y')); $global_payback->setDate(date('i'), date('G'), date('j'), date('n'), date('Y'));
$global_payback->save(); $global_payback->save();

View File

@ -10,6 +10,11 @@ body {
margin: 0; margin: 0;
} }
body>p, body>ul, body>dl {
margin-left: 1em;
margin-right: 1em;
}
fieldset { fieldset {
border: 1px solid #999; border: 1px solid #999;
margin-bottom: 1em; margin-bottom: 1em;
@ -55,18 +60,24 @@ h2 {
border-left: none; border-left: none;
} }
hr {
width: 33%;
margin-top: 2em;
margin-bottom: 2em;
}
input[type="checkbox"] { input[type="checkbox"] {
margin-left: 2em; margin-left: 2em;
} }
.center {
text-align: center;
}
.red { .red {
color: red; color: red;
} }
.center {
text-align: center;
}
.label-block { .label-block {
display: inline-block; display: inline-block;
text-align: right; text-align: right;
@ -124,12 +135,16 @@ input[type=submit] {
text-align: center text-align: center
} }
#edit_password_form, #edit_user_form, #invoice_form, #notice_form { #edit_password_form, #edit_user_form, #invoice_form, #notice_form, #global_payback_form {
width: 67%; width: 67%;
margin: auto; margin: auto;
} }
#edit_password_form p, #edit_user_form p, #notice_form p { #global_payback_form fieldset {
margin-top: 2em;
}
#edit_password_form p, #edit_user_form p, #notice_form p, #global_payback_form p {
text-align: center; text-align: center;
} }
@ -145,7 +160,7 @@ textarea#what {
width: 75%; width: 75%;
} }
#list_expenses tr:hover, #balance_table tr:not(:first-child):hover *, .highlight_td { #list_expenses tr:hover, #balance_table tr:not(:first-child):hover *, #global_paybacks_table tr:not(:first-child):hover *, .highlight_td {
background-color: green; background-color: green;
} }

View File

@ -18,7 +18,7 @@
<ul> <ul>
<li><a href="index.php?do=new_invoice">Add a bill</a></li> <li><a href="index.php?do=new_invoice">Add a bill</a></li>
<li><a href="index.php?do=password">Change your password</a></li> <li><a href="index.php?do=password">Change your password</a></li>
<li><a href="index.php?do=paybacks">See global paybacks</a></li> <li><a href="index.php?do=see_paybacks">See global paybacks</a></li>
<li><a href="index.php?do=disconnect">Disconnect</a></li> <li><a href="index.php?do=disconnect">Disconnect</a></li>
</ul> </ul>
{if condition="$current_user->getAdmin() == 1"} {if condition="$current_user->getAdmin() == 1"}

View File

@ -40,7 +40,7 @@ function toggle_password(id) {
} }
$(document).ready(function() { $(document).ready(function() {
$('#balance_table td').hover(function() { $('#balance_table td, #global_paybacks_table td').hover(function() {
$(this).closest('tr').find('td,th').addClass('highlight_td'); $(this).closest('tr').find('td,th').addClass('highlight_td');
var col = $(this).index()+1; var col = $(this).index()+1;
$(this).closest('table').find('tr :nth-child('+col+')').addClass('highlight_td'); $(this).closest('table').find('tr :nth-child('+col+')').addClass('highlight_td');
@ -50,7 +50,7 @@ $(document).ready(function() {
$(this).closest('table').find('tr :nth-child('+col+')').removeClass('highlight_td'); $(this).closest('table').find('tr :nth-child('+col+')').removeClass('highlight_td');
}); });
$('#balance_table tr:first-child th:not(:first-child)').hover(function() { $('#balance_table tr:first-child th:not(:first-child), #global_paybacks_table tr:first-child th:not(:first-child)').hover(function() {
var col = $(this).index()+1; var col = $(this).index()+1;
$(this).closest('table').find('tr :nth-child('+col+')').addClass('highlight_td'); $(this).closest('table').find('tr :nth-child('+col+')').addClass('highlight_td');
}, function() { }, function() {

View File

@ -0,0 +1,48 @@
{include="header"}
{if condition="empty($id)"}
<h2>Global paybacks list</h2>
{if condition="$global_paybacks !== FALSE"}
<dl>
{loop="$global_paybacks"}
<dt>{$value->getDate()}</dt>
<dd><a href="?do=see_paybacks&id={$value->getId()}">Payback n°{$value->getId()}</a></dd>
{/loop}
</dl>
{else}
<p>No global paybacks available.</p>
{/if}
{else}
<h2>Payback n°{$global_paybacks->getId()}</h2>
{$table=$global_paybacks->getUsersIn()->get()}
<table id="global_paybacks_table">
<tr>
<th>Owes / To</th>
{loop="$global_paybacks->getUsersIn()->get()"}
<th>{$users[$key1]->getDisplayName()}</th>
{/loop}
</tr>
{loop="$global_paybacks->getUsersIn()->get()"}
<tr>
<th>{$users[$key1]->getDisplayName()}</th>
{loop="$global_paybacks->getUsersIn()->get()"}
{if condition="$key1 == $key2"}
<td class="cell-disabled"></td>
{else}
<td>
{if condition="$table[$key1][$key2] != 0"}
<a href="?do=confirm_global_paybacks&amp;from={$key1}&amp;to={$key2}" title="Confirm payback">{$table[$key1][$key2]}</a>
{else}
-
{/if}
</td>
{/if}
{/loop}
</tr>
{/loop}
</table>
<p class="center"><a href="?do=see_paybacks">Go back to global paybacks list</a></p>
{/if}
{include="footer"}

View File

@ -160,7 +160,7 @@ textarea#what {
width: 75%; width: 75%;
} }
#list_expenses tr:hover, #balance_table tr:not(:first-child):hover *, .highlight_td { #list_expenses tr:hover, #balance_table tr:not(:first-child):hover *, #global_paybacks_table tr:not(:first-child):hover *, .highlight_td {
background-color: green; background-color: green;
} }

View File

@ -18,7 +18,7 @@
<ul> <ul>
<li><a href="index.php?do=new_invoice">Ajouter une dépense</a></li> <li><a href="index.php?do=new_invoice">Ajouter une dépense</a></li>
<li><a href="index.php?do=password">Modifier votre mot de passe</a></li> <li><a href="index.php?do=password">Modifier votre mot de passe</a></li>
<li><a href="index.php?do=paybacks">Voir les remboursements globaux</a></li> <li><a href="index.php?do=see_paybacks">Voir les remboursements globaux</a></li>
<li><a href="index.php?do=disconnect">Se déconnecter</a></li> <li><a href="index.php?do=disconnect">Se déconnecter</a></li>
</ul> </ul>
{if condition="$current_user->getAdmin() == 1"} {if condition="$current_user->getAdmin() == 1"}

View File

@ -40,7 +40,7 @@ function toggle_password(id) {
} }
$(document).ready(function() { $(document).ready(function() {
$('#balance_table td').hover(function() { $('#balance_table td, #global_paybacks_table td').hover(function() {
$(this).closest('tr').find('td,th').addClass('highlight_td'); $(this).closest('tr').find('td,th').addClass('highlight_td');
var col = $(this).index()+1; var col = $(this).index()+1;
$(this).closest('table').find('tr :nth-child('+col+')').addClass('highlight_td'); $(this).closest('table').find('tr :nth-child('+col+')').addClass('highlight_td');
@ -50,7 +50,7 @@ $(document).ready(function() {
$(this).closest('table').find('tr :nth-child('+col+')').removeClass('highlight_td'); $(this).closest('table').find('tr :nth-child('+col+')').removeClass('highlight_td');
}); });
$('#balance_table tr:first-child th:not(:first-child)').hover(function() { $('#balance_table tr:first-child th:not(:first-child), #global_paybacks_table tr:first-child th:not(:first-child)').hover(function() {
var col = $(this).index()+1; var col = $(this).index()+1;
$(this).closest('table').find('tr :nth-child('+col+')').addClass('highlight_td'); $(this).closest('table').find('tr :nth-child('+col+')').addClass('highlight_td');
}, function() { }, function() {

View File

@ -0,0 +1,48 @@
{include="header"}
{if condition="empty($id)"}
<h2>Liste des remboursements globaux</h2>
{if condition="$global_paybacks !== FALSE"}
<dl>
{loop="$global_paybacks"}
<dt>{$value->getDate()}</dt>
<dd><a href="?do=see_paybacks&id={$value->getId()}">Remboursement n°{$value->getId()}</a></dd>
{/loop}
</dl>
{else}
<p>Aucun remboursement global disponible pour l'instant.</p>
{/if}
{else}
<h2>Remboursement n°{$global_paybacks->getId()}</h2>
{$table=$global_paybacks->getUsersIn()->get()}
<table id="global_paybacks_table">
<tr>
<th>Doit / À</th>
{loop="$global_paybacks->getUsersIn()->get()"}
<th>{$users[$key1]->getDisplayName()}</th>
{/loop}
</tr>
{loop="$global_paybacks->getUsersIn()->get()"}
<tr>
<th>{$users[$key1]->getDisplayName()}</th>
{loop="$global_paybacks->getUsersIn()->get()"}
{if condition="$key1 == $key2"}
<td class="cell-disabled"></td>
{else}
<td>
{if condition="$table[$key1][$key2] != 0"}
<a href="?do=confirm_global_paybacks&amp;from={$key1}&amp;to={$key2}" title="Confirmer le remboursement">{$table[$key1][$key2]}</a>
{else}
-
{/if}
</td>
{/if}
{/loop}
</tr>
{/loop}
</table>
<p class="center"><a href="?do=see_paybacks">Retour à la liste des remboursements</a></p>
{/if}
{include="footer"}