/** * @Author: Taymoor Qanadilou * @Date created: 27/05/2013 * @Description:number of images/posts by category * @Param: * none * @Updated History: * none */ function community_by_category_report() { $db_function_obj = new DbFunctions(); $user_obj = new User(); $helper_obj = new Helper(); $posts_status_0 = $db_function_obj->number_of_posts_by_category_report('all'); $posts_status_1 = $db_function_obj->number_of_posts_by_category_report(STATUS_APPROVED); $posts_status_2 = $db_function_obj->number_of_posts_by_category_report(STATUS_DISAPPROVED); while ($post = $this->conn->db_fetch_object($posts_status_0)) { $posts[$post->cat_id] = array('cat_name' => $post->name, 'catStatusAll' => $post->count); } while ($post1 = $this->conn->db_fetch_object($posts_status_1)) { $posts[$post1->cat_id]['catStatus1'] = $post1->count; } while ($post2 = $this->conn->db_fetch_object($posts_status_2)) { $posts[$post2->cat_id]['catStatus2'] = $post2->count; } //make sure the posts array has all fields foreach ($posts as $key => $value) { if (!isset($images[$key]['catStatus1'])) { $posts[$key]['catStatus1'] = 0; } if (!isset($images[$key]['catStatus2'])) { $posts[$key]['catStatus2'] = 0; } } $images_status_0 = $db_function_obj->number_of_images_by_category_report('all'); $images_status_1 = $db_function_obj->number_of_images_by_category_report(STATUS_APPROVED); $images_status_2 = $db_function_obj->number_of_images_by_category_report(STATUS_DISAPPROVED); while ($image = $this->conn->db_fetch_object($images_status_0)) { $images[$image->cat_id] = array('cat_name' => $image->name, 'catStatusAll' => $image->count); } while ($image1 = $this->conn->db_fetch_object($images_status_1)) { $images[$image1->cat_id]['catStatus1'] = $image1->count; } while ($image2 = $this->conn->db_fetch_object($images_status_2)) { $images[$image2->cat_id]['catStatus2'] = $image2->count; } //make sure the images array has all fields foreach ($images as $key => $value) { if (!isset($images[$key]['catStatus1'])) { $images[$key]['catStatus1'] = 0; } if (!isset($images[$key]['catStatus2'])) { $images[$key]['catStatus2'] = 0; } } $output = ""; $output .= " <table border='1'>\n <tr><td colspan=5>Images by categories</td></tr>\n <tr>\n <th>Category name</th>\n <th>Count all</th>\n <th>Count not seen</th>\n <th>Count approved</th>\n <th>Count disapproved</th>\n </tr>\n "; foreach ($images as $key => $value) { $class = $helper_obj->table_row_class($i); $output .= "<tr class='{$class}'>\n <td>{$value['cat_name']}</td>\n <td>" . ($value['catStatusAll'] + 0) . "</td>\n <td>" . ($value['catStatusAll'] - $value['catStatus1'] - $value['catStatus2'] + 0) . "</td>\n <td>" . ($value['catStatus1'] + 0) . "</td>\n <td>" . ($value['catStatus2'] + 0) . "</td>\n </tr>"; } $output .= "\n </table>"; $output .= " <br /><br /><br />\n <table border='1'>\n <tr><td colspan=5>POSTS by categories</td></tr>\n <tr>\n <th>category name</th>\n <th>count all</th>\n <th>count not seen</th>\n <th>count approved</th>\n <th>count disapproved</th>\n </tr>\n "; foreach ($posts as $key => $value) { $class = $helper_obj->table_row_class($i); $output .= "<tr class='{$class}'>\n <td>{$value['cat_name']}</td>\n <td>" . ($value['catStatusAll'] + 0) . "</td>\n <td>" . ($value['catStatusAll'] - $value['catStatus1'] - $value['catStatus2'] + 0) . "</td>\n <td>" . ($value['catStatus1'] + 0) . "</td>\n <td>" . ($value['catStatus2'] + 0) . "</td>\n </tr>"; } $output .= "\n </table>"; return $output; }