diff --git a/admin/manage_categories.php b/admin/manage_categories.php index c3c85e98..3471288a 100644 --- a/admin/manage_categories.php +++ b/admin/manage_categories.php @@ -84,12 +84,6 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); ' . $mycat['name'] . ''; -} ?>
@@ -241,21 +235,22 @@ while ($mycat = hesk_dbFetchAssoc($res)) {
--> -
-
-

- -

-
- +
+
+

+ +

+
+ +
+
-
+
+ + + + + + + + + + + + + + + +
+
+
@@ -425,6 +439,9 @@ while ($mycat = hesk_dbFetchAssoc($res)) { +
+ +
diff --git a/api/BusinessLogic/Categories/Category.php b/api/BusinessLogic/Categories/Category.php index 8a1f2dc8..e2c3db9b 100644 --- a/api/BusinessLogic/Categories/Category.php +++ b/api/BusinessLogic/Categories/Category.php @@ -65,4 +65,9 @@ class Category { * @var string */ public $description; + + /** + * @var int + */ + public $numberOfTickets; } \ No newline at end of file diff --git a/api/DataAccess/Categories/CategoryGateway.php b/api/DataAccess/Categories/CategoryGateway.php index 5215a03b..5776ba30 100644 --- a/api/DataAccess/Categories/CategoryGateway.php +++ b/api/DataAccess/Categories/CategoryGateway.php @@ -15,7 +15,11 @@ class CategoryGateway extends CommonDao { function getAllCategories($hesk_settings) { $this->init(); - $sql = 'SELECT * FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'categories`'; + $sql = 'SELECT `cat`.*, COUNT(`tickets`.`id`) AS `number_of_tickets` + FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'categories` `cat` + LEFT JOIN `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'tickets` `tickets` + ON `cat`.`id` = `tickets`.`category` + GROUP BY `cat`.`id`'; $response = hesk_dbQuery($sql); @@ -35,6 +39,7 @@ class CategoryGateway extends CommonDao { $category->priority = intval($row['priority']); $category->manager = intval($row['manager']) == 0 ? NULL : intval($row['manager']); $category->description = $row['mfh_description']; + $category->numberOfTickets = intval($row['number_of_tickets']); $results[$category->id] = $category; }