/** * @Author: Taymoor Qanadilou * @Date created: 27/05/2013 * @Description:number of images/posts by country * @Param: * none * @Updated History: * none */ function community_by_country_report() { $db_functions_obj = new DbFunctions(); $ic_obj = new ImageCommunity(); $helper_obj = new Helper(); $output = ""; $posts_status_0 = $db_functions_obj->number_of_posts_by_country_report('all'); $posts_status_1 = $db_functions_obj->number_of_posts_by_country_report(STATUS_APPROVED); $posts_status_2 = $db_functions_obj->number_of_posts_by_country_report(STATUS_DISAPPROVED); while ($post = $this->conn->db_fetch_object($posts_status_0)) { $posts[$post->country_id]['catStatusAll'] = $post->count; } while ($post1 = $this->conn->db_fetch_object($posts_status_1)) { $posts[$post1->country_id]['catStatus1'] = $post1->count; } while ($post2 = $this->conn->db_fetch_object($posts_status_2)) { $posts[$post2->country_id]['catStatus2'] = $post2->count; } //make sure the posts array has all fields foreach ($posts as $key => $value) { if (!isset($posts[$key]['catStatus1'])) { $posts[$key]['catStatus1'] = 0; } if (!isset($posts[$key]['catStatus2'])) { $posts[$key]['catStatus2'] = 0; } } $images_status_0 = $db_functions_obj->number_of_images_by_country_report('all'); $images_status_1 = $db_functions_obj->number_of_images_by_country_report(STATUS_APPROVED); $images_status_2 = $db_functions_obj->number_of_images_by_country_report(STATUS_DISAPPROVED); while ($image = $this->conn->db_fetch_object($images_status_0)) { $images[$image->country_id]['catStatusAll'] = $image->count; } while ($image1 = $this->conn->db_fetch_object($images_status_1)) { $images[$image1->country_id]['catStatus1'] = $image1->count; } while ($image2 = $this->conn->db_fetch_object($images_status_2)) { $images[$image2->country_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 .= " <table border='1'>\n <tr><td colspan=5>Images by country</td></tr>\n <tr>\n <th>Country id</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 "; $countryL = $ic_obj->country_list(); foreach ($images as $key => $value) { $class = $helper_obj->table_row_class($i); $output .= "<tr class='{$class}'>\n <td>" . ($key == 0 ? "General" : $countryL[$key]) . "</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 country</td></tr>\n <tr>\n <th>Country id</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>" . ($key == 0 ? "General" : $countryL[$key]) . "</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; }