Backend functions done to add / edit a bill. Add/edit bill frontend still has bugs.

This commit is contained in:
Phyks 2013-09-08 13:52:00 +02:00
parent 63db380460
commit 98bb04e92d
6 changed files with 15 additions and 14 deletions

1
TODO
View File

@ -1,6 +1,7 @@
* Don't cache the username * Don't cache the username
* JSON output => do index view * JSON output => do index view
* API * API
* Reattribute all invoices / paybacks to unknown user when deleting a user
inc/Invoices.class.php : inc/Invoices.class.php :
======================== ========================

View File

@ -19,7 +19,8 @@
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$users_in = new UsersIn(); $this->users_in = new UsersIn();
$this->date = new DateTime();
} }
// Getters // Getters
@ -89,7 +90,7 @@
$this->what = htmlspecialchars($this->what); $this->what = htmlspecialchars($this->what);
$this->amount = (float) $this->amount; $this->amount = (float) $this->amount;
$this->buyer = (int) $this->buyer; $this->buyer = (int) $this->buyer;
$this->date = htmlspecialchars($this->date); // TODO : $this->date = htmlspecialchars($this->date);
return $this; return $this;
} }
@ -105,7 +106,7 @@
$this->setWhat($data['what']); $this->setWhat($data['what']);
$this->setAmount($data['amount']); $this->setAmount($data['amount']);
$this->setBuyer($data['buyer']); $this->setBuyer($data['buyer']);
$this->setDate($data['date']); //TODO : $this->setDate($data['date']);
} }
// Override parent load() method // Override parent load() method

View File

@ -233,9 +233,11 @@ class Storage {
foreach($this->fields as $field=>$type) { foreach($this->fields as $field=>$type) {
if(isset($this->$field)) { if(isset($this->$field)) {
if($type == 'date') if($type == 'date')
$value = $value->format('Y-m-d H:i:s'); $value = $this->$field->format('Y-m-d H:i:s');
else
$value = $this->$field;
$query->bindParam(':'.$field, $this->$field); $query->bindParam(':'.$field, $value);
} }
} }

View File

@ -57,7 +57,7 @@
$query = 'SELECT '; $query = 'SELECT ';
$i = false; $i = false;
foreach($this->fields as $field->$type) { foreach($this->fields as $field=>$type) {
if($i) { $query .= ','; } else { $i = true; } if($i) { $query .= ','; } else { $i = true; }
$query .= $field; $query .= $field;
@ -108,8 +108,8 @@
$user = -1; $user = -1;
$guests = -1; $guests = -1;
$query->bindParam(':user_id', (int) $user); $query->bindParam(':user_id', intval($user));
$query->bindParam(':guests', (int) $guests); $query->bindParam(':guests', intval($guests));
foreach($this->users_list as $user=>$guests) { foreach($this->users_list as $user=>$guests) {
$query->execute(); $query->execute();

View File

@ -396,17 +396,14 @@
$invoice->setWhat($_POST['what']); $invoice->setWhat($_POST['what']);
$invoice->setAmount($_POST['amount']); $invoice->setAmount($_POST['amount']);
$invoice->setBuyer($current_user); $invoice->setBuyer($current_user->getId());
$invoice->setDate(0, int2ampm($_POST['date_hour']), $_POST['date_day'], $_POST['date_month'], $_POST['date_year']); $invoice->setDate(0, int2ampm($_POST['date_hour']), $_POST['date_day'], $_POST['date_month'], $_POST['date_year']);
$users_in = array(); $users_in = array();
$guests = array();
foreach($_POST['users_in'] as $user) { foreach($_POST['users_in'] as $user) {
$users_in[] = (int) $user; $users_in[(int) $user] = (int) $_POST['guest_user_'.$user];
$guests[] = (int) $_POST['guest_user_'.$user];
} }
$invoice->setUsersIn($users_in); $invoice->setUsersIn($users_in);
$invoice->setGuests($guests);
$invoice->save(); $invoice->save();

View File

@ -41,7 +41,7 @@
{loop="invoices"} {loop="invoices"}
<tr> <tr>
<td>{$value->getDate()}</td> <td>{$value->getDate()}</td>
<td>{$value->getBuyer()->getDisplayName()}</td> <td>{$users[$value->getBuyer()]->getDisplayName()}</td>
<td>{$value->getUsersIn()}</td> <td>{$value->getUsersIn()}</td>
<td>{$value->getAmount()}</td> <td>{$value->getAmount()}</td>
<td>{$value->getWhat()}</td> <td>{$value->getWhat()}</td>