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
* JSON output => do index view
* API
* Reattribute all invoices / paybacks to unknown user when deleting a user
inc/Invoices.class.php :
========================

View File

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

View File

@ -233,9 +233,11 @@ class Storage {
foreach($this->fields as $field=>$type) {
if(isset($this->$field)) {
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 ';
$i = false;
foreach($this->fields as $field->$type) {
foreach($this->fields as $field=>$type) {
if($i) { $query .= ','; } else { $i = true; }
$query .= $field;
@ -108,8 +108,8 @@
$user = -1;
$guests = -1;
$query->bindParam(':user_id', (int) $user);
$query->bindParam(':guests', (int) $guests);
$query->bindParam(':user_id', intval($user));
$query->bindParam(':guests', intval($guests));
foreach($this->users_list as $user=>$guests) {
$query->execute();

View File

@ -396,17 +396,14 @@
$invoice->setWhat($_POST['what']);
$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']);
$users_in = array();
$guests = array();
foreach($_POST['users_in'] as $user) {
$users_in[] = (int) $user;
$guests[] = (int) $_POST['guest_user_'.$user];
$users_in[(int) $user] = (int) $_POST['guest_user_'.$user];
}
$invoice->setUsersIn($users_in);
$invoice->setGuests($guests);
$invoice->save();

View File

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