From 9c1330508061589b921fbc19b3359771e6743dc9 Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 8 Sep 2013 16:29:55 +0200 Subject: [PATCH] Small improvements on template --- index.php | 16 ++++++++-------- tpl/default_en/js/main.js | 7 +++++++ tpl/default_en/new_invoice.html | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index e3759f6..a3ec6c7 100644 --- a/index.php +++ b/index.php @@ -376,8 +376,7 @@ $date_year = $invoice->getDate('Y'); $amount = $invoice->getAmount(); $what = $invoice->getWhat(); - $users_in = explode(',', $invoice->getUsersIn()); - $guests = array(); + $users_in = $invoice->getUsersIn()->get(); } if(!empty($_POST['what'])) $what = $_POST['what']; @@ -385,7 +384,12 @@ if(!empty($_POST['date_day'])) $date_day = $_POST['date_day']; if(!empty($_POST['date_month'])) $date_month = $_POST['date_month']; if(!empty($_POST['date_year'])) $date_year = $_POST['date_year']; - if(!empty($_POST['users_in'])) $users_in = $_POST['users_in']; + if(!empty($_POST['users_in'])) { + $users_in = array(); + foreach($_POST['users_in'] as $user) { + $users_in[(int) $user] = (int) $_POST['guest_user_'.$user]; + } + } if(!empty($_POST['what']) && !empty($_POST['amount']) && (float) $_POST['amount'] != 0 && !empty($_POST['date_hour']) && !empty($_POST['date_day']) && !empty($_POST['date_month']) && !empty($_POST['date_year']) && !empty($_POST['users_in'])) { if(check_token(600, 'new_invoice')) { @@ -403,10 +407,7 @@ $invoice->setBuyer($current_user->getId()); $invoice->setDate(0, int2ampm($_POST['date_hour']), $_POST['date_day'], $_POST['date_month'], $_POST['date_year']); - $users_in = array(); - foreach($_POST['users_in'] as $user) { - $users_in[(int) $user] = (int) $_POST['guest_user_'.$user]; - } + $invoice->setUsersIn($users_in); $invoice->save(); @@ -441,7 +442,6 @@ $tpl->assign('what_post', (!empty($what) ? htmlspecialchars($what) : '')); $tpl->assign('users', secureDisplay($users_list)); $tpl->assign('users_in', (!empty($users_in) ? $users_in : array())); - $tpl->assign('guests', (!empty($guests) ? $guests : array())); $tpl->assign('id', (!empty($_GET['id']) ? (int) $_GET['id'] : 0)); $tpl->assign('token', generate_token('new_invoice')); $tpl->draw('new_invoice'); diff --git a/tpl/default_en/js/main.js b/tpl/default_en/js/main.js index 4d5723c..054505b 100644 --- a/tpl/default_en/js/main.js +++ b/tpl/default_en/js/main.js @@ -57,4 +57,11 @@ $(document).ready(function() { var col = $(this).index()+1; $(this).closest('table').find('tr :nth-child('+col+')').removeClass('highlight_td'); }); + + if($('#invoice_form').length) { + $('#invoice_form input[id^=users_in]').each(function () { + var id = $(this).attr('id').replace('users_in_', ''); + guest_user_label(id); + }); + } }); diff --git a/tpl/default_en/new_invoice.html b/tpl/default_en/new_invoice.html index 92856dc..7826484 100755 --- a/tpl/default_en/new_invoice.html +++ b/tpl/default_en/new_invoice.html @@ -43,7 +43,7 @@
Users in ? {loop="users"} -
and . + and .
{/loop}