From 57d6f109d0e90d46e88059f78bd8eec3e46e5ce1 Mon Sep 17 00:00:00 2001 From: Phyks Date: Sun, 8 Sep 2013 00:10:13 +0200 Subject: [PATCH] Overriding necessary method in Invoices class --- inc/Invoices.class.php | 28 +++++++++++++++++++++++----- inc/UsersIn.class.php | 9 --------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/inc/Invoices.class.php b/inc/Invoices.class.php index b2ad1aa..dbbec8e 100644 --- a/inc/Invoices.class.php +++ b/inc/Invoices.class.php @@ -32,10 +32,6 @@ return $this->date->format($format); } - public function getGuests() { - return $this->guests; - } - public function getBuyer() { return $this->buyer; } @@ -55,7 +51,7 @@ // Setters // ======= public function setId($id) { - $this->users_in->setId($id); + $this->users_in->setInvoiceId($id); $this->id = (int) $id; } @@ -111,4 +107,26 @@ $this->setBuyer($data['buyer']); $this->setDate($data['date']); } + + // Override parent load() method + // ============================= + public function load($fields = NULL, $first_only = false) { + $return = parent::load($fields, $first_only); // Execute parent load + + if($return !== false) { + foreach(array_keys($return) as $key) { + $return[$key]->users_in->load(); // Load users in for each invoice + } + } + + return $return; // Return the loaded elements + } + + // Overrid parent save() method + // ============================ + public function save() { + parent::save(); // Save invoice element + + $this->users_in->save(); // Save users in + } } diff --git a/inc/UsersIn.class.php b/inc/UsersIn.class.php index 6c4dd36..3a7f911 100644 --- a/inc/UsersIn.class.php +++ b/inc/UsersIn.class.php @@ -51,13 +51,4 @@ return $this; } - - // Restores object from array - // ========================== - public function sessionRestore($data, $serialized = false) { - // TODO *** - if($serialized) { - $data = unserialize($data); - } - } }