diff --git a/TODO b/TODO index 4fe0609..331f7ae 100755 --- a/TODO +++ b/TODO @@ -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 : ======================== diff --git a/inc/Invoices.class.php b/inc/Invoices.class.php index dbbec8e..9d801b6 100644 --- a/inc/Invoices.class.php +++ b/inc/Invoices.class.php @@ -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 diff --git a/inc/Storage.class.php b/inc/Storage.class.php index 5232d61..512e02b 100644 --- a/inc/Storage.class.php +++ b/inc/Storage.class.php @@ -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); } } diff --git a/inc/UsersIn.class.php b/inc/UsersIn.class.php index fb32814..1d2db6d 100644 --- a/inc/UsersIn.class.php +++ b/inc/UsersIn.class.php @@ -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(); diff --git a/index.php b/index.php index 0fa4aa7..a603da2 100644 --- a/index.php +++ b/index.php @@ -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(); diff --git a/tpl/default_en/index.html b/tpl/default_en/index.html index 8fe48ad..bd8f77a 100755 --- a/tpl/default_en/index.html +++ b/tpl/default_en/index.html @@ -41,7 +41,7 @@ {loop="invoices"}