From 7619135618bf2b3c1698dec0294855f2b016ff7c Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 18 Dec 2015 09:41:44 +0100 Subject: Only show assignments of that offer in offer view --- classes/BusinessAdmin.class.php | 12 +++++++----- include/offers-view.php | 5 ++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/classes/BusinessAdmin.class.php b/classes/BusinessAdmin.class.php index 20b95c4..d90e341 100644 --- a/classes/BusinessAdmin.class.php +++ b/classes/BusinessAdmin.class.php @@ -157,14 +157,15 @@ class BusinessAdmin { * @see BusinessAdmin::getAssignments() This funtion returns instances of the assignment class instead of just the ids * * @param PDO $pdo The PDO class for database connection + * @param string[] $where An array of WHERE clauses that will be AND-ed * * @throws PDOException Is something went wrong with the database * * @return int[] The ids */ - public static function getAssignmentIds($pdo) { + public static function getAssignmentIds($pdo, $where = array()) { $ids = array(); - $assignments = $pdo->query("SELECT `id` FROM `".constants::db_prefix."assignment`")->fetchAll(PDO::FETCH_ASSOC); + $assignments = $pdo->query("SELECT `id` FROM `".constants::db_prefix."assignment`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); foreach ($assignments as $assignment) { $ids[] = $assignment['id']; } @@ -177,13 +178,14 @@ class BusinessAdmin { * @see BusinessAdmin::getAssignmentIds() This function returns just the ids of the assignments, and not instances of the assignment class * * @param PDO $pdo The PDO class for database connection + * @param string[] $where An array of WHERE clauses that will be AND-ed * * @throws PDOException If something went wrong with the database * * @return assignment[] An array indexed by id of instances of the assignment class */ - public static function getAssignments($pdo) { - $ids = self::getAssignmentIds($pdo); + public static function getAssignments($pdo, $where = array()) { + $ids = self::getAssignmentIds($pdo, $where); $assignments = array(); foreach ($ids as $id) { $assignments[$id] = new assignment($pdo, $id); @@ -279,4 +281,4 @@ class BusinessAdmin { return $output; } -} \ No newline at end of file +} diff --git a/include/offers-view.php b/include/offers-view.php index b7fb092..70e3500 100644 --- a/include/offers-view.php +++ b/include/offers-view.php @@ -18,7 +18,6 @@ */ $_offer = new offer($_pdo, $_id); -$_offer->generateInvoice(); ?>
@@ -100,7 +99,7 @@ $_offer->generateInvoice(); getId()}")); foreach ($assignments as $assignment) { echo " {$assignment->getId()} @@ -127,4 +126,4 @@ $_offer->generateInvoice();
- \ No newline at end of file + -- cgit v1.2.3