Add an invoice now working

This commit is contained in:
Phyks 2013-09-08 15:54:44 +02:00
parent 98bb04e92d
commit c79cfe100c
4 changed files with 17 additions and 12 deletions

5
TODO
View File

@ -2,10 +2,13 @@
* JSON output => do index view * JSON output => do index view
* API * API
* Reattribute all invoices / paybacks to unknown user when deleting a user * Reattribute all invoices / paybacks to unknown user when deleting a user
* User groups
* cf TODO in files
inc/Invoices.class.php : inc/Invoices.class.php :
======================== ========================
* Add / Edit a bill * Edit a bill
* Error in guest input on token error
Manage paybacks : Manage paybacks :
================= =================

View File

@ -237,13 +237,13 @@ class Storage {
else else
$value = $this->$field; $value = $this->$field;
$query->bindParam(':'.$field, $value); $query->bindValue(':'.$field, $value);
} }
} }
$query->execute(); $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 // Delete function

View File

@ -5,7 +5,7 @@
class UsersIn extends Storage { class UsersIn extends Storage {
protected $invoice_id = 0, $users_list; protected $invoice_id = 0, $users_list;
//users_list is an array of users_id and number of guest per user //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( protected $fields = array(
'invoice_id'=>'int', 'invoice_id'=>'int',
'user_id'=>'int', 'user_id'=>'int',
@ -106,12 +106,11 @@
$query = $this->getConnection()->prepare($query); $query = $this->getConnection()->prepare($query);
$user = -1; $query->bindParam(':invoice_id', $this->invoice_id);
$guests = -1;
$query->bindParam(':user_id', intval($user));
$query->bindParam(':guests', intval($guests));
foreach($this->users_list as $user=>$guests) { foreach($this->users_list as $user=>$guests) {
$query->bindParam(':user_id', intval($user));
$query->bindParam(':guests', intval($guests));
$query->execute(); $query->execute();
} }
} }

View File

@ -408,7 +408,10 @@
$invoice->save(); $invoice->save();
// Clear the cache // 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); header('location: index.php?'.$get_redir);
exit(); exit();
@ -456,10 +459,10 @@
default: default:
// Display cached page in priority // 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; echo $cache;
} }
else { else { */
$users_list = new User(); $users_list = new User();
$users_list = $users_list->load(); $users_list = $users_list->load();
@ -474,5 +477,5 @@
$tpl->draw('index'); $tpl->draw('index');
break; break;
} //}
} }