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
* 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 :
=================

View File

@ -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

View File

@ -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();
}
}

View File

@ -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;
}
//}
}