aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/BusinessAdmin.class.php12
-rw-r--r--include/offers-view.php5
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();
?>
<div class="col-lg-6">
<div class="panel panel-default" id="panel-timeline">
@@ -100,7 +99,7 @@ $_offer->generateInvoice();
</thead>
<tbody>
<?php
- $assignments = BusinessAdmin::getAssignments($_pdo);
+ $assignments = BusinessAdmin::getAssignments($_pdo, array("offerId = {$_offer->getId()}"));
foreach ($assignments as $assignment) {
echo "<tr>
<td class='col-min-width'>{$assignment->getId()}</td>
@@ -127,4 +126,4 @@ $_offer->generateInvoice();
</table>
</div>
</div>
-</div> \ No newline at end of file
+</div>