From c79cfe100ca14ceecccfc88531ef5f54c18e27af Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 8 Sep 2013 15:54:44 +0200 Subject: [PATCH] Add an invoice now working --- TODO | 5 ++++- inc/Storage.class.php | 4 ++-- inc/UsersIn.class.php | 9 ++++----- index.php | 11 +++++++---- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 331f7ae..a8d3704 100755 --- a/TODO +++ b/TODO @@ -2,10 +2,13 @@ * JSON output => do index view * API * Reattribute all invoices / paybacks to unknown user when deleting a user +* User groups +* cf TODO in files inc/Invoices.class.php : ======================== -* Add / Edit a bill +* Edit a bill +* Error in guest input on token error Manage paybacks : ================= diff --git a/inc/Storage.class.php b/inc/Storage.class.php index 512e02b..3f57eac 100644 --- a/inc/Storage.class.php +++ b/inc/Storage.class.php @@ -237,13 +237,13 @@ class Storage { else $value = $this->$field; - $query->bindParam(':'.$field, $value); + $query->bindValue(':'.$field, $value); } } $query->execute(); - $this->id = (!isset($this->id) ? $this->connection->lastInsertId() : $this->id); + (empty($this->id) ? $this->setId($this->connection->lastInsertId()) : $this->setId($this->id)); } // Delete function diff --git a/inc/UsersIn.class.php b/inc/UsersIn.class.php index 1d2db6d..9acf21c 100644 --- a/inc/UsersIn.class.php +++ b/inc/UsersIn.class.php @@ -5,7 +5,7 @@ class UsersIn extends Storage { protected $invoice_id = 0, $users_list; //users_list is an array of users_id and number of guest per user - protected $TABLE_NAME = "Users_in"; + protected $TABLE_NAME = "Users_in_invoices"; protected $fields = array( 'invoice_id'=>'int', 'user_id'=>'int', @@ -106,12 +106,11 @@ $query = $this->getConnection()->prepare($query); - $user = -1; - $guests = -1; - $query->bindParam(':user_id', intval($user)); - $query->bindParam(':guests', intval($guests)); + $query->bindParam(':invoice_id', $this->invoice_id); foreach($this->users_list as $user=>$guests) { + $query->bindParam(':user_id', intval($user)); + $query->bindParam(':guests', intval($guests)); $query->execute(); } } diff --git a/index.php b/index.php index a603da2..0aaceb6 100644 --- a/index.php +++ b/index.php @@ -408,7 +408,10 @@ $invoice->save(); // Clear the cache - array_map("unlink", glob(raintpl::$cache_dir."*.rtpl.php")); + $tmp_files = glob(raintpl::$cache_dir."*.rtpl.php"); + if(is_array($tmp_files)) { + array_map("unlink", $tmp_files); + } header('location: index.php?'.$get_redir); exit(); @@ -456,10 +459,10 @@ default: // Display cached page in priority - if($cache = $tpl->cache('index', $expire_time = 600, $cache_id = $current_user->getLogin())) { + /* TODO if($cache = $tpl->cache('index', $expire_time = 600, $cache_id = $current_user->getLogin())) { echo $cache; } - else { + else { */ $users_list = new User(); $users_list = $users_list->load(); @@ -474,5 +477,5 @@ $tpl->draw('index'); break; - } + //} }